Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs4271: Disable regulators in component_probe() error path

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>

authored by

Herve Codina and committed by
Mark Brown
1e5351ba e2ff7154

+7 -3
+7 -3
sound/soc/codecs/cs4271.c
··· 581 581 582 582 ret = regcache_sync(cs4271->regmap); 583 583 if (ret < 0) 584 - return ret; 584 + goto err_disable_regulators; 585 585 586 586 ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, 587 587 CS4271_MODE2_PDN | CS4271_MODE2_CPEN, 588 588 CS4271_MODE2_PDN | CS4271_MODE2_CPEN); 589 589 if (ret < 0) 590 - return ret; 590 + goto err_disable_regulators; 591 591 ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, 592 592 CS4271_MODE2_PDN, 0); 593 593 if (ret < 0) 594 - return ret; 594 + goto err_disable_regulators; 595 595 /* Power-up sequence requires 85 uS */ 596 596 udelay(85); 597 597 ··· 601 601 CS4271_MODE2_MUTECAEQUB); 602 602 603 603 return 0; 604 + 605 + err_disable_regulators: 606 + regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); 607 + return ret; 604 608 } 605 609 606 610 static void cs4271_component_remove(struct snd_soc_component *component)