Message ID | 20250508160852.1090549-1-sakari.ailus@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | [1/1] media: v4l2-ctrls: Don't reset handler's error in v4l2_ctrl_handler_free() | expand |
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 90d25329661e..932aedc26049 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -1661,7 +1661,6 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) kvfree(hdl->buckets); hdl->buckets = NULL; hdl->cached = NULL; - hdl->error = 0; mutex_unlock(hdl->lock); mutex_destroy(&hdl->_lock); }
It's a common pattern in drivers to free the control handler's resources and then return the handler's error code on drivers' error handling paths. Alas, the v4l2_ctrl_handler_free() function also zeroes the error field, effectively indicating successful return to the caller. There's no apparent need to touch the error field while releasing the control handler's resources and cleaning up stale pointers. Not touching the handler's error field is a more certain way to address this problem than changing all the users, in which case the pattern would be likely to re-emerge in new drivers. Do just that, don't touch the control handler's error field in v4l2_ctrl_handler_free(). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- Hi all, This is currently affecting the following drivers: drivers/media/i2c/imx334.c drivers/media/i2c/imx335.c drivers/media/i2c/imx412.c drivers/media/i2c/ov2740.c drivers/media/i2c/ov5675.c drivers/media/i2c/ov9282.c drivers/media/pci/tw68/tw68-core.c drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c drivers/media/platform/samsung/s3c-camif/camif-capture.c drivers/media/platform/verisilicon/hantro_drv.c drivers/media/test-drivers/visl/visl-core.c The fact that one of them is a test driver tells a lot. :-) The patch is untested. If we agree to do this, the patch should probably be cc'd to stable, too. - Sakari drivers/media/v4l2-core/v4l2-ctrls-core.c | 1 - 1 file changed, 1 deletion(-)