]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: i2c: imx258: add missing mutex protection for format code access
authorZiyi Guo <n7l8m4@u.northwestern.edu>
Fri, 30 Jan 2026 02:31:54 +0000 (02:31 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 11 Mar 2026 00:05:38 +0000 (01:05 +0100)
commitc3109ecc3bb76aab9ef65f2e795a97a764a0b4a3
tree6e47caa35e6d8123712bf82679c032293a46becc
parent46c2891cf12c767de031a248cbb1f96d203bd3f6
media: i2c: imx258: add missing mutex protection for format code access

imx258_open(), imx258_enum_mbus_code(), and imx258_enum_frame_size()
call imx258_get_format_code() without holding imx258->mutex. However,
imx258_get_format_code() has lockdep_assert_held(&imx258->mutex)
indicating that callers must hold this lock.

All other callers of imx258_get_format_code() properly acquire the mutex:
- imx258_set_pad_format() acquires mutex at imx258.c:918
- imx258_get_pad_format() acquires mutex at imx258.c:896

The mutex is needed to protect access to imx258->vflip->val and
imx258->hflip->val which are used to calculate the bayer format code.

Add mutex_lock()/mutex_unlock() around the imx258_get_format_code()
calls in the affected functions to fix the missing lock protection.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/imx258.c