diff options
author | Ian Abbott | 2013-11-08 16:03:36 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2013-11-12 01:16:44 +0100 |
commit | 616a3548e816553c31d57cc211a86d327a192e12 (patch) | |
tree | 14399017e14d1c1e2bb182acf718ec01f2001238 /drivers | |
parent | staging: comedi: use refcount in comedi_driver_unregister() (diff) | |
download | kernel-qcow2-linux-616a3548e816553c31d57cc211a86d327a192e12.tar.gz kernel-qcow2-linux-616a3548e816553c31d57cc211a86d327a192e12.tar.xz kernel-qcow2-linux-616a3548e816553c31d57cc211a86d327a192e12.zip |
staging: comedi: use refcount while reading /proc/comedi
In the seq_file 'show' handler for "/proc/comedi" - `comedi_read()` in
"comedi/proc.c", call `comedi_dev_get_from_minor()` instead of
`comedi_dev_from_minor()` to increment the reference counter for the
`struct comedi_device` while it is being examined. Call
`comedi_dev_put()` to decrement the reference afterwards. Also acquire
the `attach_lock` rwsem while checking whether the device is attached.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/proc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index ade00035d3bb..da6bc5855ebc 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -41,16 +41,20 @@ static int comedi_read(struct seq_file *m, void *v) "driver_name, board_name, n_subdevices"); for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { - struct comedi_device *dev = comedi_dev_from_minor(i); + struct comedi_device *dev = comedi_dev_get_from_minor(i); + if (!dev) continue; + down_read(&dev->attach_lock); if (dev->attached) { devices_q = 1; seq_printf(m, "%2d: %-20s %-20s %4d\n", i, dev->driver->driver_name, dev->board_name, dev->n_subdevices); } + up_read(&dev->attach_lock); + comedi_dev_put(dev); } if (!devices_q) seq_puts(m, "no devices\n"); |