Browse Source

iio: buffer: check if a buffer has been set up when poll is called

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>
Stefan Windfeldt-Prytz 7 years ago
parent
commit
4cd140bda6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/iio/industrialio-buffer.c

+ 1 - 1
drivers/iio/industrialio-buffer.c

@@ -175,7 +175,7 @@ unsigned int iio_buffer_poll(struct file *filp,
 	struct iio_dev *indio_dev = filp->private_data;
 	struct iio_dev *indio_dev = filp->private_data;
 	struct iio_buffer *rb = indio_dev->buffer;
 	struct iio_buffer *rb = indio_dev->buffer;
 
 
-	if (!indio_dev->info)
+	if (!indio_dev->info || rb == NULL)
 		return 0;
 		return 0;
 
 
 	poll_wait(filp, &rb->pollq, wait);
 	poll_wait(filp, &rb->pollq, wait);