summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorIwona Winiarska <iwona.winiarska@intel.com>2021-12-03 01:31:15 +0300
committerIwona Winiarska <iwona.winiarska@intel.com>2021-12-15 14:57:09 +0300
commit563fbb157523d69fe75e5ecdfd667e833110c0b5 (patch)
treeed689123617655adb6c8df42a8c85a02f4f55f92 /drivers
parentc1000fe8c34d287c6526041e7f890548bfba993e (diff)
downloadlinux-563fbb157523d69fe75e5ecdfd667e833110c0b5.tar.xz
i2c: core: Fix hold_lock mutex is uninitialized
The hold_lock mutex is uninitialized when used, causing the warning: [ 2.273892] WARNING: CPU: 0 PID: 1 at kernel/locking/mutex.c:575 __mutex_lock+0x8f8/0xb5c [ 2.283107] DEBUG_LOCKS_WARN_ON(lock->magic != lock) Initialize the hold_lock mutex before using it. Also, move INIT_DELAYED_WORK() closer to other init functions to improve readability. Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com> Change-Id: I26dda2451f8d27e947866d627f1909c9654f20aa
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/i2c-core-base.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9eaf3f89aa7f..be242605df91 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1570,8 +1570,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
adap->locked_flags = 0;
rt_mutex_init(&adap->bus_lock);
rt_mutex_init(&adap->mux_lock);
+ mutex_init(&adap->hold_lock);
mutex_init(&adap->userspace_clients_lock);
INIT_LIST_HEAD(&adap->userspace_clients);
+ INIT_DELAYED_WORK(&adap->unhold_work, i2c_adapter_unhold_work);
/* Set default timeout to 1 second if not already set */
if (adap->timeout == 0) {
@@ -1636,9 +1638,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
mutex_unlock(&core_lock);
- mutex_init(&adap->hold_lock);
- INIT_DELAYED_WORK(&adap->unhold_work, i2c_adapter_unhold_work);
-
return 0;
out_reg: