diff mbox series

ASoC: ti: davinci-mcasp: fix possible reference leak in __davinci_mcasp_set_clkdiv

Message ID 20201030153626.94150-1-zhangqilong3@huawei.com
State New
Headers show
Series ASoC: ti: davinci-mcasp: fix possible reference leak in __davinci_mcasp_set_clkdiv | expand

Commit Message

Zhang Qilong Oct. 30, 2020, 3:36 p.m. UTC
pm_runtime_get_sync() will increment pm usage counter whatever it
does. Forgetting to call pm_runtime_put will result in reference
leak in __davinci_mcasp_set_clkdiv, so we should fix it.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 sound/soc/ti/davinci-mcasp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
index a6b72ad53b43..4b46dd827f3f 100644
--- a/sound/soc/ti/davinci-mcasp.c
+++ b/sound/soc/ti/davinci-mcasp.c
@@ -607,6 +607,8 @@  static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id,
 				      int div, bool explicit)
 {
+	int ret = 0;
+
 	pm_runtime_get_sync(mcasp->dev);
 	switch (div_id) {
 	case MCASP_CLKDIV_AUXCLK:			/* MCLK divider */
@@ -644,11 +646,11 @@  static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id,
 		break;
 
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 
 	pm_runtime_put(mcasp->dev);
-	return 0;
+	return ret;
 }
 
 static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id,