staging: comedi: get mutex before subdevice in attribute functions
authorIan Abbott <abbotti@mev.co.uk>
Thu, 4 Apr 2013 13:59:08 +0000 (14:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 21:33:20 +0000 (14:33 -0700)
commit7f4656c5f780520262f7eeda926844761e859c6b
treee60997be79a6a353d9b301738536277fbdc33b7c
parent7a4e5a9f3c9f002b36fa91c1accae8f9b5c66cc8
staging: comedi: get mutex before subdevice in attribute functions

The comedi device attribute functions such as
`show_read_buffer_kb()` or `show_write_buffer_kb()` call
`comedi_read_subdevice()` or `comedi_write_subdevice()` without
acquiring the comedi device's mutex first, although the functions do
acquire the mutex afterwards.  Change them to acquire the mutex first.
This is consistent with most of the comedi device file operation
functions (apart from `comedi_read()` and `comedi_write()` which
probably need looking at).

Despite the use of the mutex, there are still race conditions as the
`struct comedi_file_info *info` variable value set before acquiring the
mutex could be stale after acquiring the mutex.  This problem will be
dealt with once reference counting has been implemented for the comedi
devices.

This patch also adds local variable `struct comedi_device *dev` to the
functions to reduce the use of the `info` variable a little bit.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c
This page took 0.03926 seconds and 5 git commands to generate.