staging: comedi: check s->async for poll(), read() and write()
authorIan Abbott <abbotti@mev.co.uk>
Wed, 27 Feb 2013 10:56:19 +0000 (10:56 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 6 Mar 2013 03:23:50 +0000 (03:23 +0000)
commit1ff13c78ca3975a94460a6a0b49acf9a787ed350
treed889e1d1ba4ec5a710e768956f1d7c35b895882d
parent35ad1797ad99b8e73758c805803021cbda799dcb
staging: comedi: check s->async for poll(), read() and write()

commit cc400e185c07c15a42d2635995f422de5b94b696 upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/staging/comedi/comedi_fops.c