diff mbox series

ALSA: ac97: fix reference leak in ac97_bus_remove

Message ID 20201030153210.92234-1-zhangqilong3@huawei.com (mailing list archive)
State New, archived
Headers show
Series ALSA: ac97: fix reference leak in ac97_bus_remove | expand

Commit Message

Zhang Qilong Oct. 30, 2020, 3:32 p.m. UTC
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@huawei.com>
---
 sound/ac97/bus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

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);