Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aca1b4f7 authored by Zhang Shurong's avatar Zhang Shurong Committed by Greg Kroah-Hartman
Browse files

media: ov2659: Fix memory leaks in ov2659_probe()



commit 76142b137b968d47b35cdd8d1dc924677d319c8b upstream.

ov2659_probe() doesn't properly free control handler resources in failure
paths, causing memory leaks. Add v4l2_ctrl_handler_free() to prevent these
memory leaks and reorder the ctrl_handler assignment for better code flow.

Fixes: c4c0283a ("[media] media: i2c: add support for omnivision's ov2659 sensor")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c35e7c7a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1432,14 +1432,15 @@ static int ov2659_probe(struct i2c_client *client)
				     V4L2_CID_TEST_PATTERN,
				     ARRAY_SIZE(ov2659_test_pattern_menu) - 1,
				     0, 0, ov2659_test_pattern_menu);
	ov2659->sd.ctrl_handler = &ov2659->ctrls;

	if (ov2659->ctrls.error) {
		dev_err(&client->dev, "%s: control initialization error %d\n",
			__func__, ov2659->ctrls.error);
		v4l2_ctrl_handler_free(&ov2659->ctrls);
		return  ov2659->ctrls.error;
	}

	ov2659->sd.ctrl_handler = &ov2659->ctrls;
	sd = &ov2659->sd;
	client->flags |= I2C_CLIENT_SCCB;
#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API