diff mbox

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

Message ID 1518679721-17415-1-git-send-email-stefan.windfeldt@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Windfeldt-Prytz Feb. 15, 2018, 7:28 a.m. UTC
If no iio buffer has been set up and poll is called return 0.

Signed-off-by: Stefan Windfeldt-Prytz <stefan.windfeldt@axis.com>
---
Changes in v2:
- Removed Change-Id

 drivers/iio/industrialio-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lars-Peter Clausen Feb. 15, 2018, 7:33 a.m. UTC | #1
On 02/15/2018 08:28 AM, Stefan Windfeldt-Prytz wrote:
> If no iio buffer has been set up and poll is called return 0.
> 

This is a pretty bad bug, thanks for fixing this.

The commit message should include a section about the consequences of
missing check.

It looks like the issue goes back all the way to the beginning and the fix
needs to be backported to all stable releases.

> Signed-off-by: Stefan Windfeldt-Prytz <stefan.windfeldt@axis.com>
> ---
> Changes in v2:
> - Removed Change-Id
> 
>  drivers/iio/industrialio-buffer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 79abf70..cd5bfe3 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -175,7 +175,7 @@ __poll_t 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);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 79abf70..cd5bfe3 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -175,7 +175,7 @@  __poll_t 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);