From: Stefan Windfeldt-Prytz Date: Thu, 15 Feb 2018 14:02:53 +0000 (+0100) Subject: iio: buffer: check if a buffer has been set up when poll is called X-Git-Tag: v4.1.50~36 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4aac881c7ed52922858c8f550e529b6a6861fcba;p=users%2Fdwmw2%2Flinux.git iio: buffer: check if a buffer has been set up when poll is called [ Upstream commit 4cd140bda6494543f1c1b0ccceceaa44b676eef6 ] 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 Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 7fa280b28ecb7..ec6b26f008d93 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -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);