[PATCH] ALSA: ac97: fix reference leak in ac97_bus_remove

Zhang Qilong zhangqilong3 at huawei.com
Fri Oct 30 16:32:10 CET 2020


pm_runtime_get_sync() will increase pm usage counter even it
failed. We should call pm_runtime_put_noidle to decrease it
to prevent reference leak.

Signed-off-by: Zhang Qilong <zhangqilong3 at huawei.com>
---
 sound/ac97/bus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
index 7985dd8198b6..2c4779d851ad 100644
--- a/sound/ac97/bus.c
+++ b/sound/ac97/bus.c
@@ -521,8 +521,11 @@ static int ac97_bus_remove(struct device *dev)
 	int ret;
 
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0)
+	if (ret < 0) {
+		dev_err(dev, "Failed to enable device: %d\n", ret);
+		pm_runtime_put_noidle(dev);
 		return ret;
+	}
 
 	ret = adrv->remove(adev);
 	pm_runtime_put_noidle(dev);
-- 
2.17.1



More information about the Alsa-devel mailing list