From e06fdaefd159410df88c6b3e2cf84a82a267dbb8 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 24 Apr 2025 17:04:19 +0100 Subject: [PATCH] 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 --- drivers/media/i2c/imx477.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/media/i2c/imx477.c +++ b/drivers/media/i2c/imx477.c @@ -1513,8 +1513,10 @@ static int imx477_enum_mbus_code(struct if (code->index >= (ARRAY_SIZE(codes) / 4)) return -EINVAL; + mutex_lock(&imx477->mutex); code->code = imx477_get_format_code(imx477, codes[code->index * 4]); + mutex_unlock(&imx477->mutex); } else { if (code->index > 0) return -EINVAL; @@ -1530,6 +1532,7 @@ static int imx477_enum_frame_size(struct struct v4l2_subdev_frame_size_enum *fse) { struct imx477 *imx477 = to_imx477(sd); + u32 code; if (fse->pad >= NUM_PADS) return -EINVAL; @@ -1543,7 +1546,11 @@ static int imx477_enum_frame_size(struct if (fse->index >= num_modes) return -EINVAL; - if (fse->code != imx477_get_format_code(imx477, fse->code)) + mutex_lock(&imx477->mutex); + code = imx477_get_format_code(imx477, fse->code); + mutex_unlock(&imx477->mutex); + + if (fse->code != code) return -EINVAL; fse->min_width = mode_list[fse->index].width;