]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: ov5648: Fix lockdep error
authorHans de Goede <hdegoede@redhat.com>
Thu, 3 Feb 2022 12:33:12 +0000 (13:33 +0100)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 3 Mar 2022 22:27:05 +0000 (00:27 +0200)
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.

Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/media/i2c/ov5648.c

index 3478650ee732a6cf4ffd70fd7e8930447da98083..930ff6897044a46ba812a4bed0fcd32aea1f5ac9 100644 (file)
@@ -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 */