Skip to content

Commit

Permalink
ASoC: mediatek: mtk-btcvsd: Fix an error handling path in 'mtk_btcvsd…
Browse files Browse the repository at this point in the history
…_snd_probe()'

[ Upstream commit b6052c3 ]

If an error occurs after a successful 'of_iomap()' call, it must be undone
by a corresponding 'iounmap()' call, as already done in the remove
function.

While at it, remove the useless initialization of 'ret' at the beginning of
the function.

Fixes: 4bd8597 ("ASoC: mediatek: add btcvsd driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0c2ba562c3364e61bfbd5b3013a99dfa0d9045d7.1622989685.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tititiou36 authored and gregkh committed Jul 14, 2021
1 parent 92a30a9 commit d4d3cd4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions sound/soc/mediatek/common/mtk-btcvsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = {

static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
{
int ret = 0;
int ret;
int irq_id;
u32 offset[5] = {0, 0, 0, 0, 0};
struct mtk_btcvsd_snd *btcvsd;
Expand Down Expand Up @@ -1337,15 +1337,17 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
btcvsd->bt_sram_bank2_base = of_iomap(dev->of_node, 1);
if (!btcvsd->bt_sram_bank2_base) {
dev_err(dev, "iomap bt_sram_bank2_base fail\n");
return -EIO;
ret = -EIO;
goto unmap_pkv_err;
}

btcvsd->infra = syscon_regmap_lookup_by_phandle(dev->of_node,
"mediatek,infracfg");
if (IS_ERR(btcvsd->infra)) {
dev_err(dev, "cannot find infra controller: %ld\n",
PTR_ERR(btcvsd->infra));
return PTR_ERR(btcvsd->infra);
ret = PTR_ERR(btcvsd->infra);
goto unmap_bank2_err;
}

/* get offset */
Expand All @@ -1354,7 +1356,7 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
ARRAY_SIZE(offset));
if (ret) {
dev_warn(dev, "%s(), get offset fail, ret %d\n", __func__, ret);
return ret;
goto unmap_bank2_err;
}
btcvsd->infra_misc_offset = offset[0];
btcvsd->conn_bt_cvsd_mask = offset[1];
Expand All @@ -1373,8 +1375,18 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE);
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->rx, BT_SCO_STATE_IDLE);

return devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
NULL, 0);
ret = devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
NULL, 0);
if (ret)
goto unmap_bank2_err;

return 0;

unmap_bank2_err:
iounmap(btcvsd->bt_sram_bank2_base);
unmap_pkv_err:
iounmap(btcvsd->bt_pkv_base);
return ret;
}

static int mtk_btcvsd_snd_remove(struct platform_device *pdev)
Expand Down

0 comments on commit d4d3cd4

Please sign in to comment.