* [PATCH] ASoC: cs4271: Fix regulator leak on probe failure
@ 2025-11-05 6:22 Haotian Zhang
2025-11-05 8:43 ` Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Haotian Zhang @ 2025-11-05 6:22 UTC (permalink / raw)
To: david.rhodes, rf, lgirdwood, broonie, perex, tiwai
Cc: linux-sound, patches, linux-kernel, Haotian Zhang
The probe function enables regulators at the beginning
but fails to disable them in its error handling path.
If any operation after enabling the regulators fails,
the probe will exit with an error, leaving the regulators
permanently enabled, which could lead to a resource leak.
Add a proper error handling path to call regulator_bulk_disable()
before returning an error.
Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
sound/soc/codecs/cs4271.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 6a3cca3d26c7..ead447a5da7f 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -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_regulator;
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_regulator;
ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
CS4271_MODE2_PDN, 0);
if (ret < 0)
- return ret;
+ goto err_disable_regulator;
/* 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_regulator:
+ regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies);
+ return ret;
}
static void cs4271_component_remove(struct snd_soc_component *component)
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: cs4271: Fix regulator leak on probe failure
2025-11-05 6:22 [PATCH] ASoC: cs4271: Fix regulator leak on probe failure Haotian Zhang
@ 2025-11-05 8:43 ` Markus Elfring
2025-11-05 11:54 ` Mark Brown
2025-11-06 11:03 ` Charles Keepax
2025-11-06 23:54 ` Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-11-05 8:43 UTC (permalink / raw)
To: vulab, linux-sound, patches
Cc: LKML, David Rhodes, Jaroslav Kysela, Liam Girdwood, Mark Brown,
Richard Fitzgerald, Takashi Iwai
> The probe function enables regulators at the beginning
> but fails to disable them in its error handling path.
…
Would an other word wrapping be a bit nicer for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc4#n658
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: cs4271: Fix regulator leak on probe failure
2025-11-05 8:43 ` Markus Elfring
@ 2025-11-05 11:54 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-11-05 11:54 UTC (permalink / raw)
To: Markus Elfring
Cc: vulab, linux-sound, patches, LKML, David Rhodes, Jaroslav Kysela,
Liam Girdwood, Richard Fitzgerald, Takashi Iwai
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
On Wed, Nov 05, 2025 at 09:43:13AM +0100, Markus Elfring wrote:
> > The probe function enables regulators at the beginning
> > but fails to disable them in its error handling path.
> …
>
> Would an other word wrapping be a bit nicer for such a change description?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc4#n658
Feel free to ignore Markus, he has a long history of sending
unhelpful review comments and continues to ignore repeated requests
to stop.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: cs4271: Fix regulator leak on probe failure
2025-11-05 6:22 [PATCH] ASoC: cs4271: Fix regulator leak on probe failure Haotian Zhang
2025-11-05 8:43 ` Markus Elfring
@ 2025-11-06 11:03 ` Charles Keepax
2025-11-06 23:54 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2025-11-06 11:03 UTC (permalink / raw)
To: Haotian Zhang
Cc: david.rhodes, rf, lgirdwood, broonie, perex, tiwai, linux-sound,
patches, linux-kernel
On Wed, Nov 05, 2025 at 02:22:46PM +0800, Haotian Zhang wrote:
> The probe function enables regulators at the beginning
> but fails to disable them in its error handling path.
> If any operation after enabling the regulators fails,
> the probe will exit with an error, leaving the regulators
> permanently enabled, which could lead to a resource leak.
>
> Add a proper error handling path to call regulator_bulk_disable()
> before returning an error.
>
> Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: cs4271: Fix regulator leak on probe failure
2025-11-05 6:22 [PATCH] ASoC: cs4271: Fix regulator leak on probe failure Haotian Zhang
2025-11-05 8:43 ` Markus Elfring
2025-11-06 11:03 ` Charles Keepax
@ 2025-11-06 23:54 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-11-06 23:54 UTC (permalink / raw)
To: david.rhodes, rf, lgirdwood, perex, tiwai, Haotian Zhang
Cc: linux-sound, patches, linux-kernel
On Wed, 05 Nov 2025 14:22:46 +0800, Haotian Zhang wrote:
> The probe function enables regulators at the beginning
> but fails to disable them in its error handling path.
> If any operation after enabling the regulators fails,
> the probe will exit with an error, leaving the regulators
> permanently enabled, which could lead to a resource leak.
>
> Add a proper error handling path to call regulator_bulk_disable()
> before returning an error.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: cs4271: Fix regulator leak on probe failure
commit: 6b6eddc63ce871897d3a5bc4f8f593e698aef104
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-06 23:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 6:22 [PATCH] ASoC: cs4271: Fix regulator leak on probe failure Haotian Zhang
2025-11-05 8:43 ` Markus Elfring
2025-11-05 11:54 ` Mark Brown
2025-11-06 11:03 ` Charles Keepax
2025-11-06 23:54 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox