]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: cs4271: Disable regulators in component_probe() error path
authorHerve Codina <herve.codina@bootlin.com>
Wed, 29 Oct 2025 09:39:18 +0000 (10:39 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 29 Oct 2025 20:13:24 +0000 (20:13 +0000)
The commit 9a397f473657 ("ASoC: cs4271: add regulator consumer support")
has introduced regulators in the driver.

Regulators are enabled at the beginning of component_probe() but they
are not disabled on errors. This can lead to unbalanced enable/disable.

Fix the error path to disable regulators on errors.

Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support")
Cc: stable@vger.kernel.org
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://patch.msgid.link/20251029093921.624088-3-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs4271.c

index 0ed73ba3625c9014abf7657e734c053982d0aaf7..f636900e0c1adc47533684263c1c5a735d63aeac 100644 (file)
@@ -581,17 +581,17 @@ static int cs4271_component_probe(struct snd_soc_component *component)
 
        ret = regcache_sync(cs4271->regmap);
        if (ret < 0)
-               return ret;
+               goto err_disable_regulators;
 
        ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
                                 CS4271_MODE2_PDN | CS4271_MODE2_CPEN,
                                 CS4271_MODE2_PDN | CS4271_MODE2_CPEN);
        if (ret < 0)
-               return ret;
+               goto err_disable_regulators;
        ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
                                 CS4271_MODE2_PDN, 0);
        if (ret < 0)
-               return ret;
+               goto err_disable_regulators;
        /* Power-up sequence requires 85 uS */
        udelay(85);
 
@@ -601,6 +601,10 @@ static int cs4271_component_probe(struct snd_soc_component *component)
                                   CS4271_MODE2_MUTECAEQUB);
 
        return 0;
+
+err_disable_regulators:
+       regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies);
+       return ret;
 }
 
 static void cs4271_component_remove(struct snd_soc_component *component)