]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: tegra: fix pm_runtime leak on mutex_lock failure
authorSaurav Sachidanand <sauravsc@amazon.com>
Thu, 7 May 2026 22:11:44 +0000 (22:11 +0000)
committerAndi Shyti <andi.shyti@kernel.org>
Wed, 13 May 2026 22:14:06 +0000 (00:14 +0200)
If tegra_i2c_mutex_lock() fails, the function returns without calling
pm_runtime_put(), leaking the runtime PM reference acquired by the
preceding pm_runtime_get_sync(). This prevents the device from ever
entering runtime suspend.

Add the missing pm_runtime_put() before returning on lock failure.

Fixes: 6077cfd716fb ("i2c: tegra: Add support for SW mutex register")
Signed-off-by: Saurav Sachidanand <sauravsc@amazon.com>
Cc: <stable@vger.kernel.org> # v7.0+
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260507221145.62183-2-sauravsc@amazon.com
drivers/i2c/busses/i2c-tegra.c

index 9fd5ade774a0b98247c2cee8dd8c63c591f0b9aa..c24b8de0a9c7b3ef43b32457a7a5e5e18102a97f 100644 (file)
@@ -1666,8 +1666,10 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
        }
 
        ret = tegra_i2c_mutex_lock(i2c_dev);
-       if (ret)
+       if (ret) {
+               pm_runtime_put(i2c_dev->dev);
                return ret;
+       }
 
        for (i = 0; i < num; i++) {
                enum msg_end_type end_type = MSG_END_STOP;