Skip to content

Commit e24d5dd

Browse files
CassivsGabriellisbroonie
authored andcommitted
ASoC: mediatek: mt8192: Check runtime resume during probe
The MT8192 AFE probe enables runtime PM temporarily while reinitializing the regmap cache from hardware, but it uses pm_runtime_get_sync() without checking the return value. If runtime resume fails, probe keeps going without the device necessarily being accessible, and pm_runtime_get_sync() may leave the PM usage count incremented. The regmap_reinit_cache() failure path also returns before dropping the temporary PM reference and before clearing pm_runtime_bypass_reg_ctl. Use pm_runtime_resume_and_get() so resume failures do not leak a usage count, and clear the temporary bypass flag after dropping the probe PM reference on all regmap_reinit_cache() outcomes. Fixes: 125ab5d ("ASoC: mediatek: mt8192: add platform driver") Cc: stable@vger.kernel.org Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260527-asoc-mt8192-probe-cleanup-v1-2-1bb834d05b72@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 965e17a commit e24d5dd

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

sound/soc/mediatek/mt8192/mt8192-afe-pcm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,15 +2227,19 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
22272227

22282228
/* enable clock for regcache get default value from hw */
22292229
afe_priv->pm_runtime_bypass_reg_ctl = true;
2230-
pm_runtime_get_sync(dev);
2230+
ret = pm_runtime_resume_and_get(dev);
2231+
if (ret) {
2232+
afe_priv->pm_runtime_bypass_reg_ctl = false;
2233+
return dev_err_probe(dev, ret, "failed to resume device\n");
2234+
}
22312235

22322236
ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config);
2233-
if (ret)
2234-
return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
2235-
22362237
pm_runtime_put_sync(dev);
22372238
afe_priv->pm_runtime_bypass_reg_ctl = false;
22382239

2240+
if (ret)
2241+
return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
2242+
22392243
regcache_cache_only(afe->regmap, true);
22402244
regcache_mark_dirty(afe->regmap);
22412245

0 commit comments

Comments
 (0)