Skip to content

Commit 0bd6c51

Browse files
6by9popcornmix
authored andcommitted
media: i2c: imx477: Fix lockdep errors
imx477_get_format_code has a lockdep_assert_held test, however the call paths from enum_mbus_code and enum_frame_size don't lock the mutex before calling it. Add in the relevant mutex locking. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 6899542 commit 0bd6c51

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/media/i2c/imx477.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,8 +1513,10 @@ static int imx477_enum_mbus_code(struct v4l2_subdev *sd,
15131513
if (code->index >= (ARRAY_SIZE(codes) / 4))
15141514
return -EINVAL;
15151515

1516+
mutex_lock(&imx477->mutex);
15161517
code->code = imx477_get_format_code(imx477,
15171518
codes[code->index * 4]);
1519+
mutex_unlock(&imx477->mutex);
15181520
} else {
15191521
if (code->index > 0)
15201522
return -EINVAL;
@@ -1530,6 +1532,7 @@ static int imx477_enum_frame_size(struct v4l2_subdev *sd,
15301532
struct v4l2_subdev_frame_size_enum *fse)
15311533
{
15321534
struct imx477 *imx477 = to_imx477(sd);
1535+
u32 code;
15331536

15341537
if (fse->pad >= NUM_PADS)
15351538
return -EINVAL;
@@ -1543,7 +1546,11 @@ static int imx477_enum_frame_size(struct v4l2_subdev *sd,
15431546
if (fse->index >= num_modes)
15441547
return -EINVAL;
15451548

1546-
if (fse->code != imx477_get_format_code(imx477, fse->code))
1549+
mutex_lock(&imx477->mutex);
1550+
code = imx477_get_format_code(imx477, fse->code);
1551+
mutex_unlock(&imx477->mutex);
1552+
1553+
if (fse->code != code)
15471554
return -EINVAL;
15481555

15491556
fse->min_width = mode_list[fse->index].width;

0 commit comments

Comments
 (0)