kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] [media] mem2mem_testdev: unlock and return error code properly
@ 2012-08-14  6:58 Dan Carpenter
  2012-08-17  7:34 ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-08-14  6:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, Marek Szyprowski, Tomasz Moń,
	Guennadi Liakhovetski, linux-media, kernel-janitors

We recently added locking to this function, but there was an error path
which accidentally returned holding a lock.  Also we returned zero on
failure on some paths instead of the error code.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Applies to linux-next.

diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index 0aa8c47..0b496f3 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -911,10 +911,9 @@ static int m2mtest_open(struct file *file)
 	v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_time_msec, NULL);
 	v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_num_bufs, NULL);
 	if (hdl->error) {
-		int err = hdl->error;
-
+		rc = hdl->error;
 		v4l2_ctrl_handler_free(hdl);
-		return err;
+		goto open_unlock;
 	}
 	ctx->fh.ctrl_handler = hdl;
 	v4l2_ctrl_handler_setup(hdl);
@@ -946,7 +945,7 @@ static int m2mtest_open(struct file *file)
 
 open_unlock:
 	mutex_unlock(&dev->dev_mutex);
-	return 0;
+	return rc;
 }
 
 static int m2mtest_release(struct file *file)

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

* RE: [patch] [media] mem2mem_testdev: unlock and return error code properly
  2012-08-14  6:58 [patch] [media] mem2mem_testdev: unlock and return error code properly Dan Carpenter
@ 2012-08-17  7:34 ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2012-08-17  7:34 UTC (permalink / raw)
  To: 'Dan Carpenter', 'Mauro Carvalho Chehab'
  Cc: 'Hans Verkuil', 'Tomasz Moń',
	'Guennadi Liakhovetski', linux-media, kernel-janitors

Hi Dan,

On Tuesday, August 14, 2012 8:59 AM Dan Carpenter wrote:

> We recently added locking to this function, but there was an error path
> which accidentally returned holding a lock.  Also we returned zero on
> failure on some paths instead of the error code.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for the patch!

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
> Applies to linux-next.
> 
> diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
> index 0aa8c47..0b496f3 100644
> --- a/drivers/media/video/mem2mem_testdev.c
> +++ b/drivers/media/video/mem2mem_testdev.c
> @@ -911,10 +911,9 @@ static int m2mtest_open(struct file *file)
>  	v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_time_msec, NULL);
>  	v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_num_bufs, NULL);
>  	if (hdl->error) {
> -		int err = hdl->error;
> -
> +		rc = hdl->error;
>  		v4l2_ctrl_handler_free(hdl);
> -		return err;
> +		goto open_unlock;
>  	}
>  	ctx->fh.ctrl_handler = hdl;
>  	v4l2_ctrl_handler_setup(hdl);
> @@ -946,7 +945,7 @@ static int m2mtest_open(struct file *file)
> 
>  open_unlock:
>  	mutex_unlock(&dev->dev_mutex);
> -	return 0;
> +	return rc;
>  }
> 
>  static int m2mtest_release(struct file *file)


Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center



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

end of thread, other threads:[~2012-08-17  7:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14  6:58 [patch] [media] mem2mem_testdev: unlock and return error code properly Dan Carpenter
2012-08-17  7:34 ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).