summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2013-02-05 13:50:40 +0100
committerGreg Kroah-Hartman2013-02-05 20:23:32 +0100
commitcc400e185c07c15a42d2635995f422de5b94b696 (patch)
tree101b8c0466ace7355e678331e2041afdded61908 /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: remove 'comedi_autoconfig' module parameter (diff)
downloadkernel-qcow2-linux-cc400e185c07c15a42d2635995f422de5b94b696.tar.gz
kernel-qcow2-linux-cc400e185c07c15a42d2635995f422de5b94b696.tar.xz
kernel-qcow2-linux-cc400e185c07c15a42d2635995f422de5b94b696.zip
staging: comedi: check s->async for poll(), read() and write()
Some low-level comedi drivers (incorrectly) point `dev->read_subdev` or `dev->write_subdev` to a subdevice that does not support asynchronous commands. Comedi's poll(), read() and write() file operation handlers assume these subdevices do support asynchronous commands. In particular, they assume `s->async` is valid (where `s` points to the read or write subdevice), which it won't be if it has been set incorrectly. This can lead to a NULL pointer dereference. Check `s->async` is non-NULL in `comedi_poll()`, `comedi_read()` and `comedi_write()` to avoid the bug. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index bd89e785fe6c..b1e8cdbd1ce7 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1839,7 +1839,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
}
s = comedi_read_subdevice(info);
- if (s) {
+ if (s && s->async) {
poll_wait(file, &s->async->wait_head, wait);
if (!s->busy || !comedi_is_subdevice_running(s) ||
comedi_buf_read_n_available(s->async) > 0)
@@ -1847,7 +1847,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
}
s = comedi_write_subdevice(info);
- if (s) {
+ if (s && s->async) {
unsigned int bps = bytes_per_sample(s->async->subdevice);
poll_wait(file, &s->async->wait_head, wait);
@@ -1882,7 +1882,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
}
s = comedi_write_subdevice(info);
- if (!s)
+ if (!s || !s->async)
return -EIO;
async = s->async;
@@ -1977,7 +1977,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
}
s = comedi_read_subdevice(info);
- if (!s)
+ if (!s || !s->async)
return -EIO;
async = s->async;