All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3] iio: buffer: check if a buffer has been set up when poll is called
@ 2018-02-15 14:02 Stefan Windfeldt-Prytz
  2018-02-17 16:56 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Windfeldt-Prytz @ 2018-02-15 14:02 UTC (permalink / raw)
  To: jic23; +Cc: knaack.h, lars, ppmeerw, linux-iio, Stefan Windfeldt-Prytz

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>
---
Changes in v3:
- Added consequences of missing the check

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);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCHv3] iio: buffer: check if a buffer has been set up when poll is called
  2018-02-15 14:02 [PATCHv3] iio: buffer: check if a buffer has been set up when poll is called Stefan Windfeldt-Prytz
@ 2018-02-17 16:56 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-02-17 16:56 UTC (permalink / raw)
  To: Stefan Windfeldt-Prytz
  Cc: knaack.h, lars, ppmeerw, linux-iio, Stefan Windfeldt-Prytz

On Thu, 15 Feb 2018 15:02:53 +0100
Stefan Windfeldt-Prytz <stefan.windfeldt@axis.com> wrote:

> 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>
Applied to the fixes-togreg-post-rc1 branch of iio.git.

Thanks,

Jonathan

> ---
> Changes in v3:
> - Added consequences of missing the check
> 
> 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);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-17 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 14:02 [PATCHv3] iio: buffer: check if a buffer has been set up when poll is called Stefan Windfeldt-Prytz
2018-02-17 16:56 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.