Skip to content

Commit 0018b57

Browse files
tititiou36smb49
authored andcommitted
ASoC: mediatek: mtk-btcvsd: Fix an error handling path in 'mtk_btcvsd_snd_probe()'
BugLink: https://bugs.launchpad.net/bugs/1938199 [ 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> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8d9789d commit 0018b57

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
@@ -1302,7 +1302,7 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = {
13021302

13031303
static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13041304
{
1305-
int ret = 0;
1305+
int ret;
13061306
int irq_id;
13071307
u32 offset[5] = {0, 0, 0, 0, 0};
13081308
struct mtk_btcvsd_snd *btcvsd;
@@ -1358,15 +1358,17 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13581358
btcvsd->bt_sram_bank2_base = of_iomap(dev->of_node, 1);
13591359
if (!btcvsd->bt_sram_bank2_base) {
13601360
dev_err(dev, "iomap bt_sram_bank2_base fail\n");
1361-
return -EIO;
1361+
ret = -EIO;
1362+
goto unmap_pkv_err;
13621363
}
13631364

13641365
btcvsd->infra = syscon_regmap_lookup_by_phandle(dev->of_node,
13651366
"mediatek,infracfg");
13661367
if (IS_ERR(btcvsd->infra)) {
13671368
dev_err(dev, "cannot find infra controller: %ld\n",
13681369
PTR_ERR(btcvsd->infra));
1369-
return PTR_ERR(btcvsd->infra);
1370+
ret = PTR_ERR(btcvsd->infra);
1371+
goto unmap_bank2_err;
13701372
}
13711373

13721374
/* get offset */
@@ -1375,7 +1377,7 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13751377
ARRAY_SIZE(offset));
13761378
if (ret) {
13771379
dev_warn(dev, "%s(), get offset fail, ret %d\n", __func__, ret);
1378-
return ret;
1380+
goto unmap_bank2_err;
13791381
}
13801382
btcvsd->infra_misc_offset = offset[0];
13811383
btcvsd->conn_bt_cvsd_mask = offset[1];
@@ -1394,8 +1396,18 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
13941396
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE);
13951397
mtk_btcvsd_snd_set_state(btcvsd, btcvsd->rx, BT_SCO_STATE_IDLE);
13961398

1397-
return devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
1398-
NULL, 0);
1399+
ret = devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
1400+
NULL, 0);
1401+
if (ret)
1402+
goto unmap_bank2_err;
1403+
1404+
return 0;
1405+
1406+
unmap_bank2_err:
1407+
iounmap(btcvsd->bt_sram_bank2_base);
1408+
unmap_pkv_err:
1409+
iounmap(btcvsd->bt_pkv_base);
1410+
return ret;
13991411
}
14001412

14011413
static int mtk_btcvsd_snd_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)