mem2mem_testdev: unlock and return error code properly
Subsystems (2)
PATCH 1/1 mem2mem_testdev: unlock and return error code properly
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 <[email protected]>
---
Applies to linux-next.
drivers/media/video/mem2mem_testdev.c +3 -4
@@ -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)
Hi Dan,
Quoted 5 lines · Dan Carpenter
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 <[email protected]>
Thanks for the patch!
Acked-by Marek Szyprowski <[email protected]>
Quoted 21 lines
---
Applies to linux-next.drivers/media/video/mem2mem_testdev.c +2
-3@@ -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);
drivers/media/video/mem2mem_testdev.c static int m2mtest_open(struct file *file) · line 951
Quoted 8 lines
drivers/media/video/mem2mem_testdev.c +1
-1@@ -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
Signature · 2 lines
Marek Szyprowski Samsung Poland R&D Center