Skip to content

Commit

Permalink
ASoC: hisilicon: fix missing clk_disable_unprepare() on error in hi62…
Browse files Browse the repository at this point in the history
…10_i2s_startup()

[ Upstream commit 375904e ]

After calling clk_prepare_enable(), clk_disable_unprepare() need
be called when calling clk_set_rate() failed.

Fixes: 0bf750f ("ASoC: hisilicon: Add hi6210 i2s audio driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210518044514.607010-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed Jul 14, 2021
1 parent 2541d78 commit d4ebf35
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sound/soc/hisilicon/hi6210-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,15 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,

for (n = 0; n < i2s->clocks; n++) {
ret = clk_prepare_enable(i2s->clk[n]);
if (ret) {
while (n--)
clk_disable_unprepare(i2s->clk[n]);
return ret;
}
if (ret)
goto err_unprepare_clk;
}

ret = clk_set_rate(i2s->clk[CLK_I2S_BASE], 49152000);
if (ret) {
dev_err(i2s->dev, "%s: setting 49.152MHz base rate failed %d\n",
__func__, ret);
return ret;
goto err_unprepare_clk;
}

/* enable clock before frequency division */
Expand Down Expand Up @@ -165,6 +162,11 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,
hi6210_write_reg(i2s, HII2S_SW_RST_N, val);

return 0;

err_unprepare_clk:
while (n--)
clk_disable_unprepare(i2s->clk[n]);
return ret;
}

static void hi6210_i2s_shutdown(struct snd_pcm_substream *substream,
Expand Down

0 comments on commit d4ebf35

Please sign in to comment.