summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Windfeldt-Prytz <stefan.windfeldt@axis.com>2018-02-15 17:02:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-28 12:16:17 +0300
commit2433724adee7eac0f461d17afeb84f06c9b48973 (patch)
tree7b54f812a44c854d5d16a665d08d1d7750eabcfa
parentd8db7b0d70256505acedc6fe072cfcbf6116545d (diff)
downloadlinux-2433724adee7eac0f461d17afeb84f06c9b48973.tar.xz
iio: buffer: check if a buffer has been set up when poll is called
commit 4cd140bda6494543f1c1b0ccceceaa44b676eef6 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/iio/industrialio-buffer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 25c68de393ad..1f64457cc6ba 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -92,7 +92,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);