soundwire: debugfs: fix unbalanced pm_runtime_put()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 17 May 2023 16:37:50 +0000 (18:37 +0200)
committerVinod Koul <vkoul@kernel.org>
Mon, 29 May 2023 05:19:46 +0000 (10:49 +0530)
If pm_runtime_resume_and_get() failed with -EACCES, the driver continued
execution and finally called pm_runtime_put_autosuspend().  Since
pm_runtime_resume_and_get() drops the usage counter on every error, this
lead to double decrement of that counter.

Fixes: b275bf45ba1d ("soundwire: debugfs: Switch to sdw_read_no_pm")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230517163750.997629-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/debugfs.c

index dea782e0edc4be65fe79ee18e78336993c32780c..c3a1a359ee5c3f91479c685cce76f876bf5035bd 100644 (file)
@@ -56,8 +56,9 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
        if (!buf)
                return -ENOMEM;
 
-       ret = pm_runtime_resume_and_get(&slave->dev);
+       ret = pm_runtime_get_sync(&slave->dev);
        if (ret < 0 && ret != -EACCES) {
+               pm_runtime_put_noidle(&slave->dev);
                kfree(buf);
                return ret;
        }