Skip to content
/ linux Public

Commit cabd025

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 c9af181 commit cabd025

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
@@ -1430,15 +1430,15 @@ static int ov5647_probe(struct i2c_client *client)
14301430

14311431
sensor->mode = OV5647_DEFAULT_MODE;
14321432

1433-
ret = ov5647_init_controls(sensor);
1434-
if (ret)
1435-
goto mutex_destroy;
1436-
14371433
sd = &sensor->sd;
14381434
v4l2_i2c_subdev_init(sd, client, &ov5647_subdev_ops);
14391435
sd->internal_ops = &ov5647_subdev_internal_ops;
14401436
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
14411437

1438+
ret = ov5647_init_controls(sensor);
1439+
if (ret)
1440+
goto mutex_destroy;
1441+
14421442
sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
14431443
sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
14441444
ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad);

0 commit comments

Comments
 (0)