]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: rj54n1cb0c: Fix memleak in rj54n1_probe()
authorZhang Shurong <zhang_shurong@foxmail.com>
Tue, 24 Jun 2025 08:27:24 +0000 (16:27 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 25 Aug 2025 13:40:36 +0000 (15:40 +0200)
rj54n1_probe() won't clean all the allocated resources in fail
path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to
prevent memleak.

Fixes: f187352dcd45 ("media: i2c: Copy rj54n1cb0c soc_camera sensor driver")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/rj54n1cb0c.c

index b7ca39f63dba847555bb9e27d87185d0166ad214..6dfc912168510fb1bd308f834911f9de705844b7 100644 (file)
@@ -1329,10 +1329,13 @@ static int rj54n1_probe(struct i2c_client *client)
                        V4L2_CID_GAIN, 0, 127, 1, 66);
        v4l2_ctrl_new_std(&rj54n1->hdl, &rj54n1_ctrl_ops,
                        V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
-       rj54n1->subdev.ctrl_handler = &rj54n1->hdl;
-       if (rj54n1->hdl.error)
-               return rj54n1->hdl.error;
 
+       if (rj54n1->hdl.error) {
+               ret = rj54n1->hdl.error;
+               goto err_free_ctrl;
+       }
+
+       rj54n1->subdev.ctrl_handler = &rj54n1->hdl;
        rj54n1->clk_div         = clk_div;
        rj54n1->rect.left       = RJ54N1_COLUMN_SKIP;
        rj54n1->rect.top        = RJ54N1_ROW_SKIP;