[PATCH v2 2/9] i2c: atr: unlock mutex after c2a access

Cosmin Tanislav
2025-02-25T11:39:50Z

i2c_atr_release_alias(), i2c_atr_destroy_c2a(), and c2a access, are
protected everywhere with alias_pairs_lock, use it here too.

i2c_atr_destroy_c2a() accesses the elements inside alias_pairs, which
needs to be mutex protected.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
drivers/i2c/i2c-atr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c
index 39b3b95c6842..f6033c99f474 100644
--- a/drivers/i2c/i2c-atr.c
+++ b/drivers/i2c/i2c-atr.c
@@ -544,8 +544,6 @@ static void i2c_atr_detach_addr(struct i2c_adapter *adapter,
return;
}

- mutex_unlock(&chan->alias_pairs_lock);
-
i2c_atr_release_alias(chan->alias_pool, c2a->alias);

dev_dbg(atr->dev,
@@ -553,6 +551,8 @@ static void i2c_atr_detach_addr(struct i2c_adapter *adapter,
chan->chan_id, c2a->alias, addr);

i2c_atr_destroy_c2a(&c2a);
+
+ mutex_unlock(&chan->alias_pairs_lock);
}

static int i2c_atr_bus_notifier_call(struct notifier_block *nb,
--
2.48.1