]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: es8328: Add error unwind in resume
authorHsieh Hung-En <hungen3108@gmail.com>
Fri, 30 Jan 2026 16:00:17 +0000 (00:00 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 2 Feb 2026 12:50:03 +0000 (12:50 +0000)
Handle failures in the resume path by unwinding previously enabled
resources.

If enabling regulators or syncing the regcache fails, disable regulators
and unprepare the clock to avoid leaking resources and leaving the device
in a partially resumed state.

Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com>
Link: https://patch.msgid.link/20260130160017.2630-6-hungen3108@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/es8328.c

index 7afc97c62587e51ab3d1daac8fb578f3eb2335c7..9838fe42cb6fca3ac97b0db672383013d3129c0c 100644 (file)
@@ -784,17 +784,23 @@ static int es8328_resume(struct snd_soc_component *component)
                                        es8328->supplies);
        if (ret) {
                dev_err(component->dev, "unable to enable regulators\n");
-               return ret;
+               goto err_clk;
        }
 
        regcache_mark_dirty(es8328->regmap);
        ret = regcache_sync(es8328->regmap);
        if (ret) {
                dev_err(component->dev, "unable to sync regcache\n");
-               return ret;
+               goto err_regulators;
        }
 
        return 0;
+
+err_regulators:
+       regulator_bulk_disable(ARRAY_SIZE(es8328->supplies), es8328->supplies);
+err_clk:
+       clk_disable_unprepare(es8328->clk);
+       return ret;
 }
 
 static int es8328_component_probe(struct snd_soc_component *component)