:p
atchew
Login
If an error occurs after media_entity_pads_init() is called, the media entity is left uncleaned, potentially leaking resources or leaving it in an invalid state. Similarly, the remove path misses the cleanup. Add a dedicated error_entity_cleanup label so that media_entity_cleanup() is only invoked on the error path when media_entity_pads_init() has actually succeeded. Also add media_entity_cleanup() to rdacm21_remove() to ensure proper resource release on driver unload. Fixes: a59f853b3b4b ("media: i2c: Add driver for RDACM21 camera module") Signed-off-by: Biren Pandya <birenpandya@gmail.com> --- Changes in v3: - Added a blank line after media_entity_cleanup() in the error path (Sakari). Changes in v2: - Fixed a bug in v1's probe error handling where media_entity_cleanup() could be called on an uninitialized entity. - Added Signed-off-by tag which was missing in v1. --- drivers/media/i2c/rdacm21.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c index XXXXXXX..XXXXXXX 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -XXX,XX +XXX,XX @@ static int rdacm21_probe(struct i2c_client *client) ret = v4l2_async_register_subdev(&dev->sd); if (ret) - goto error_free_ctrls; + goto error_entity_cleanup; return 0; +error_entity_cleanup: + media_entity_cleanup(&dev->sd.entity); + error_free_ctrls: v4l2_ctrl_handler_free(&dev->ctrls); - media_entity_cleanup(&dev->sd.entity); error: i2c_unregister_device(dev->isp); -- 2.50.1 (Apple Git-155)
If an error occurs after media_entity_pads_init() is called, the media entity is left uncleaned, potentially leaking resources or leaving it in an invalid state. Similarly, the remove path misses the cleanup. Add a dedicated error_entity_cleanup label so that media_entity_cleanup() is only invoked on the error path when media_entity_pads_init() has actually succeeded. Also add media_entity_cleanup() to rdacm21_remove() to ensure proper resource release on driver unload. Fixes: a59f853b3b4b ("media: i2c: Add driver for RDACM21 camera module") Signed-off-by: Biren Pandya <birenpandya@gmail.com> --- Changes in v4: - Rebased onto latest linux-media next branch to resolve a merge conflict in rdacm21.c (as reported by Media CI). Changes in v3: - Added a blank line after media_entity_cleanup() in the error path (Sakari). Changes in v2: - Fixed a bug in v1's probe error handling where media_entity_cleanup() could be called on an uninitialized entity. - Added Signed-off-by tag which was missing in v1. --- drivers/media/i2c/rdacm21.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c index XXXXXXX..XXXXXXX 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -XXX,XX +XXX,XX @@ static int rdacm21_probe(struct i2c_client *client) ret = v4l2_async_register_subdev(&dev->sd); if (ret) - goto error_free_ctrls; + goto error_entity_cleanup; return 0; +error_entity_cleanup: + media_entity_cleanup(&dev->sd.entity); + error_free_ctrls: v4l2_ctrl_handler_free(&dev->ctrls); error: -- 2.50.1 (Apple Git-155)