public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails
@ 2011-07-04 15:15 Guennadi Liakhovetski
  2011-07-04 15:29 ` Bastian Hecht
  0 siblings, 1 reply; 2+ messages in thread
From: Guennadi Liakhovetski @ 2011-07-04 15:15 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Bastian Hecht

If vb2_dma_contig_get_userptr() fails on a videobuffer, driver's
.buf_init() method will not be called and the list will not be
initialised. Trying to remove an uninitialised element from a list leads
to a NULL-dereference.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/video/sh_mobile_ceu_camera.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 3ae5c9c..a851a3e 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -421,8 +421,12 @@ static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
 		pcdev->active = NULL;
 	}
 
-	/* Doesn't hurt also if the list is empty */
-	list_del_init(&buf->queue);
+	/*
+	 * Doesn't hurt also if the list is empty, but it hurts, if queuing the
+	 * buffer failed, and .buf_init() hasn't been called
+	 */
+	if (buf->queue.next)
+		list_del_init(&buf->queue);
 
 	spin_unlock_irq(&pcdev->lock);
 }
-- 
1.7.2.5

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

* Re: [PATCH] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails
  2011-07-04 15:15 [PATCH] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails Guennadi Liakhovetski
@ 2011-07-04 15:29 ` Bastian Hecht
  0 siblings, 0 replies; 2+ messages in thread
From: Bastian Hecht @ 2011-07-04 15:29 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List



On Mon, 4 Jul 2011, Guennadi Liakhovetski wrote:

> If vb2_dma_contig_get_userptr() fails on a videobuffer, driver's
> .buf_init() method will not be called and the list will not be
> initialised. Trying to remove an uninitialised element from a list leads
> to a NULL-dereference.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Tested on mackerel.

Tested-by: Bastian Hecht <hechtb@gmail.com>

Thanks,

 Bastian

> ---
>  drivers/media/video/sh_mobile_ceu_camera.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
> index 3ae5c9c..a851a3e 100644
> --- a/drivers/media/video/sh_mobile_ceu_camera.c
> +++ b/drivers/media/video/sh_mobile_ceu_camera.c
> @@ -421,8 +421,12 @@ static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
>  		pcdev->active = NULL;
>  	}
>  
> -	/* Doesn't hurt also if the list is empty */
> -	list_del_init(&buf->queue);
> +	/*
> +	 * Doesn't hurt also if the list is empty, but it hurts, if queuing the
> +	 * buffer failed, and .buf_init() hasn't been called
> +	 */
> +	if (buf->queue.next)
> +		list_del_init(&buf->queue);
>  
>  	spin_unlock_irq(&pcdev->lock);
>  }
> -- 
> 1.7.2.5
> 

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

end of thread, other threads:[~2011-07-04 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-04 15:15 [PATCH] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails Guennadi Liakhovetski
2011-07-04 15:29 ` Bastian Hecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox