]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: buffer: check if a buffer has been set up when poll is called
authorStefan Windfeldt-Prytz <stefan.windfeldt@axis.com>
Thu, 15 Feb 2018 14:02:53 +0000 (15:02 +0100)
committerSasha Levin <alexander.levin@microsoft.com>
Sun, 4 Mar 2018 15:28:34 +0000 (10:28 -0500)
[ 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 <stefan.windfeldt@axis.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/iio/industrialio-buffer.c

index 7fa280b28ecb70101d7d9693f0aa623225e5f037..ec6b26f008d93bbd238ad1a8a7376da3f49665f4 100644 (file)
@@ -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);