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
[ Upstream commit 4cd140b ]

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: [email protected]
Signed-off-by: Stefan Windfeldt-Prytz <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Stefan Windfeldt-Prytz authored and Sasha Levin committed Mar 4, 2018
1 parent 953eb3c commit 4aac881
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 @@ -150,7 +150,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 4aac881

Please sign in to comment.