Skip to content
/ linux Public

Commit 59e372a

Browse files
jailuthraSasha Levin
authored andcommitted
media: i2c: ov5647: Initialize subdev before controls
[ Upstream commit eee13cb ] In ov5647_init_controls() we call v4l2_get_subdevdata, but it is initialized by v4l2_i2c_subdev_init() in the probe, which currently happens after init_controls(). This can result in a segfault if the error condition is hit, and we try to access i2c_client, so fix the order. Fixes: 4974c2f ("media: ov5647: Support gain, exposure and AWB controls") Cc: stable@vger.kernel.org Suggested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9aae0f3 commit 59e372a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/media/i2c/ov5647.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,15 +1400,15 @@ static int ov5647_probe(struct i2c_client *client)
14001400

14011401
sensor->mode = OV5647_DEFAULT_MODE;
14021402

1403-
ret = ov5647_init_controls(sensor);
1404-
if (ret)
1405-
goto mutex_destroy;
1406-
14071403
sd = &sensor->sd;
14081404
v4l2_i2c_subdev_init(sd, client, &ov5647_subdev_ops);
14091405
sd->internal_ops = &ov5647_subdev_internal_ops;
14101406
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
14111407

1408+
ret = ov5647_init_controls(sensor);
1409+
if (ret)
1410+
goto mutex_destroy;
1411+
14121412
sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
14131413
sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
14141414
ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad);

0 commit comments

Comments
 (0)