Skip to content

Commit b6052c3

Browse files
tititiou36broonie
authored andcommitted
ASoC: mediatek: mtk-btcvsd: Fix an error handling path in 'mtk_btcvsd_snd_probe()'
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>
1 parent d08c5b7 commit b6052c3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

sound/soc/mediatek/common/mtk-btcvsd.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = {
12811281

12821282
static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
12831283
{
1284-
int ret = 0;
1284+
int ret;
12851285
int irq_id;
12861286
u32 offset[5] = {0, 0, 0, 0, 0};
12871287
struct mtk_btcvsd_snd *btcvsd;
@@ -1337,15 +1337,17 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13371337
btcvsd->bt_sram_bank2_base = of_iomap(dev->of_node, 1);
13381338
if (!btcvsd->bt_sram_bank2_base) {
13391339
dev_err(dev, "iomap bt_sram_bank2_base fail\n");
1340-
return -EIO;
1340+
ret = -EIO;
1341+
goto unmap_pkv_err;
13411342
}
13421343

13431344
btcvsd->infra = syscon_regmap_lookup_by_phandle(dev->of_node,
13441345
"mediatek,infracfg");
13451346
if (IS_ERR(btcvsd->infra)) {
13461347
dev_err(dev, "cannot find infra controller: %ld\n",
13471348
PTR_ERR(btcvsd->infra));
1348-
return PTR_ERR(btcvsd->infra);
1349+
ret = PTR_ERR(btcvsd->infra);
1350+
goto unmap_bank2_err;
13491351
}
13501352

13511353
/* get offset */
@@ -1354,7 +1356,7 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13541356
ARRAY_SIZE(offset));
13551357
if (ret) {
13561358
dev_warn(dev, "%s(), get offset fail, ret %d\n", __func__, ret);
1357-
return ret;
1359+
goto unmap_bank2_err;
13581360
}
13591361
btcvsd->infra_misc_offset = offset[0];
13601362
btcvsd->conn_bt_cvsd_mask = offset[1];
@@ -1373,8 +1375,18 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13731375
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE);
13741376
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->rx, BT_SCO_STATE_IDLE);
13751377

1376-
return devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
1377-
NULL, 0);
1378+
ret = devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
1379+
NULL, 0);
1380+
if (ret)
1381+
goto unmap_bank2_err;
1382+
1383+
return 0;
1384+
1385+
unmap_bank2_err:
1386+
iounmap(btcvsd->bt_sram_bank2_base);
1387+
unmap_pkv_err:
1388+
iounmap(btcvsd->bt_pkv_base);
1389+
return ret;
13781390
}
13791391

13801392
static int mtk_btcvsd_snd_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)