]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: realtek: use devm_mutex_init for regmap lock
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Mon, 27 Jul 2026 01:56:09 +0000 (22:56 -0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Jul 2026 01:42:27 +0000 (18:42 -0700)
With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() needs to be called
before the lock is discarded. Use devm_mutex_init() instead so the
cleanup is handled automatically.

Fixes: 907e772f6f6de ("net: dsa: realtek: allow subdrivers to externally lock regmap")
Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
Link: https://patch.msgid.link/20260726-realtek_mutext-v2-2-5d62ba998791@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/realtek/rtl83xx.c

index 71124ecca92f2a134143f0eb1de448cee6be6772..9402bfe4f85afbe48837f555543dc4033a1af619 100644 (file)
@@ -156,7 +156,10 @@ rtl83xx_probe(struct device *dev,
        if (!priv)
                return ERR_PTR(-ENOMEM);
 
-       mutex_init(&priv->map_lock);
+       ret = devm_mutex_init(dev, &priv->map_lock);
+       if (ret)
+               return ERR_PTR(ret);
+
        mutex_init(&priv->vlan_lock);
        mutex_init(&priv->l2_lock);