media: i2c: ov5648: Fix lockdep error
Subsystems (2)
PATCH v2 1/1 media: i2c: ov5648: Fix lockdep error
ov5648_state_init() calls ov5648_state_mipi_configure() which uses __v4l2_ctrl_s_ctrl[_int64](). This means that sensor->mutex (which is also sensor->ctrls.handler.lock) must be locked before calling ov5648_state_init().
ov5648_state_mipi_configure() is also used in other places where the lock is already held so it cannot be changed itself.
Note this is based on an identical (tested) fix for the ov8865 driver, this has only been compile-tested.
---
Changes in v2:
- Move the taking of the mutex to inside ov5648_state_init()
--- drivers/media/i2c/ov5648.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5648.c +8 -2
@@ -1778,8 +1778,14 @@ static int ov5648_state_configure(struct ov5648_sensor *sensor,static int ov5648_state_init (struct ov5648_sensor *sensor) { -return ov5648_state_configure (sensor, &ov5648_modes[0 ], - ov5648_mbus_codes[0 ]); +int ret; + +mutex_lock (&sensor->mutex); + ret =ov5648_state_configure (sensor, &ov5648_modes[0 ], + ov5648_mbus_codes[0 ]); +mutex_unlock (&sensor->mutex); + +return ret; }/* Sensor Base */
Signature · 1 line
2.33.1
Hi,
Quoted 10 lines · Hans de Goede
ov5648_state_init()callsov5648_state_mipi_configure()which uses __v4l2_ctrl_s_ctrl[_int64](). This means thatsensor->mutex(which is alsosensor->ctrls.handler.lock) must be locked before callingov5648_state_init().
ov5648_state_mipi_configure()is also used in other places where the lock is already held so it cannot be changed itself.Note this is based on an identical (tested) fix for the ov8865 driver, this has only been compile-tested.
Thanks!
Paul
Quoted 33 lines
Cc Paul Kocialkowski <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:
- Move the taking of the mutex to insideov5648_state_init()--- drivers/media/i2c/ov5648.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/media/i2c/ov5648.c +8
-2@@ -1778,8 +1778,14 @@ static int ov5648_state_configure(struct ov5648_sensor *sensor,static int ov5648_state_init (struct ov5648_sensor *sensor) { -return ov5648_state_configure (sensor, &ov5648_modes[0 ], - ov5648_mbus_codes[0 ]); +int ret; + +mutex_lock (&sensor->mutex); + ret =ov5648_state_configure (sensor, &ov5648_modes[0 ], + ov5648_mbus_codes[0 ]); +mutex_unlock (&sensor->mutex); + +return ret; }/* Sensor Base */ Signature · 1 line
2.33.1
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com