Skip to content

Commit

Permalink
iio: buffer: check if a buffer has been set up when poll is called
Browse files Browse the repository at this point in the history
If no iio buffer has been set up and poll is called return 0.
Without this check there will be a null pointer dereference when
calling poll on a iio driver without an iio buffer.

Cc: stable@vger.kernel.org
Signed-off-by: Stefan Windfeldt-Prytz <stefan.windfeldt@axis.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Stefan Windfeldt-Prytz authored and Jonathan Cameron committed Feb 17, 2018
1 parent f027e0b commit 4cd140b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/industrialio-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ unsigned int iio_buffer_poll(struct file *filp,
struct iio_dev *indio_dev = filp->private_data;
struct iio_buffer *rb = indio_dev->buffer;

if (!indio_dev->info)
if (!indio_dev->info || rb == NULL)
return 0;

poll_wait(filp, &rb->pollq, wait);
Expand Down

0 comments on commit 4cd140b

Please sign in to comment.