Skip to content

Commit 6899542

Browse files
6by9popcornmix
authored andcommitted
media: i2c: imx708: Fix lockdep issues.
The driver had a lockdep_assert_held in imx708_get_format_code, but the calls from enum_mbus_code and enum_frame_size didn't take the mutex. Likewise imx708_set_framing_limits calling __v4l2_ctrl_modify_range had a lockdep, but when going through the probe function the mutex hadn't been taken. Fix both cases. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 0805662 commit 6899542

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/media/i2c/imx708.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,9 @@ static int imx708_enum_mbus_code(struct v4l2_subdev *sd,
12581258
if (code->index >= (ARRAY_SIZE(codes) / 4))
12591259
return -EINVAL;
12601260

1261+
mutex_lock(&imx708->mutex);
12611262
code->code = imx708_get_format_code(imx708);
1263+
mutex_unlock(&imx708->mutex);
12621264
} else {
12631265
if (code->index > 0)
12641266
return -EINVAL;
@@ -1274,6 +1276,7 @@ static int imx708_enum_frame_size(struct v4l2_subdev *sd,
12741276
struct v4l2_subdev_frame_size_enum *fse)
12751277
{
12761278
struct imx708 *imx708 = to_imx708(sd);
1279+
u32 code;
12771280

12781281
if (fse->pad >= NUM_PADS)
12791282
return -EINVAL;
@@ -1288,7 +1291,11 @@ static int imx708_enum_frame_size(struct v4l2_subdev *sd,
12881291
if (fse->index >= num_modes)
12891292
return -EINVAL;
12901293

1291-
if (fse->code != imx708_get_format_code(imx708))
1294+
mutex_lock(&imx708->mutex);
1295+
code = imx708_get_format_code(imx708);
1296+
mutex_unlock(&imx708->mutex);
1297+
1298+
if (fse->code != code)
12921299
return -EINVAL;
12931300

12941301
fse->min_width = mode_list[fse->index].width;
@@ -1900,7 +1907,9 @@ static int imx708_init_controls(struct imx708 *imx708)
19001907
imx708->sd.ctrl_handler = ctrl_hdlr;
19011908

19021909
/* Setup exposure and frame/line length limits. */
1910+
mutex_lock(&imx708->mutex);
19031911
imx708_set_framing_limits(imx708);
1912+
mutex_unlock(&imx708->mutex);
19041913

19051914
return 0;
19061915

0 commit comments

Comments
 (0)