]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: mediatek: mt8192: Check runtime resume during probe
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Wed, 27 May 2026 13:55:47 +0000 (10:55 -0300)
committerMark Brown <broonie@kernel.org>
Tue, 2 Jun 2026 15:13:06 +0000 (16:13 +0100)
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: 125ab5d588b0 ("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>
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c

index 9f5057eeeff970ac52525d812a57fccd72cce35c..db0ae44a86afead9292608ab9e9af65a8aa4cedc 100644 (file)
@@ -2227,15 +2227,19 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
 
        /* enable clock for regcache get default value from hw */
        afe_priv->pm_runtime_bypass_reg_ctl = true;
-       pm_runtime_get_sync(dev);
+       ret = pm_runtime_resume_and_get(dev);
+       if (ret) {
+               afe_priv->pm_runtime_bypass_reg_ctl = false;
+               return dev_err_probe(dev, ret, "failed to resume device\n");
+       }
 
        ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config);
-       if (ret)
-               return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
-
        pm_runtime_put_sync(dev);
        afe_priv->pm_runtime_bypass_reg_ctl = false;
 
+       if (ret)
+               return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
+
        regcache_cache_only(afe->regmap, true);
        regcache_mark_dirty(afe->regmap);