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>
}
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)
}
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);
}
s = comedi_write_subdevice(info);
- if (!s)
+ if (!s || !s->async)
return -EIO;
async = s->async;
}
s = comedi_read_subdevice(info);
- if (!s)
+ if (!s || !s->async)
return -EIO;
async = s->async;