* [PATCH 1/2] ASoC: cs35l56: Fix missing calls to wm_adsp2_remove()
2026-06-09 12:07 [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
@ 2026-06-09 12:07 ` Richard Fitzgerald
2026-06-09 12:07 ` [PATCH 2/2] ASoC: cs35l56: Cleanup if component_probe fails Richard Fitzgerald
2026-06-09 13:02 ` [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
2 siblings, 0 replies; 6+ messages in thread
From: Richard Fitzgerald @ 2026-06-09 12:07 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
Call wm_adsp2_remove() in cs35l56_remove() and the error path of
cs35l56_common_probe().
Depends on commit 7d3fb78b5503 ("ASoC: wm_adsp: Fix NULL dereference
when removing firmware controls").
The call to wm_halo_init() during driver probe should be paired with
a call to wm_adsp2_remove() but this was missing. The consequence
would be a memory leak of the control lists in the cs_dsp driver.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e49611252900 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
---
sound/soc/codecs/cs35l56.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index b4b126753c10..5de9cf3d0330 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -1997,11 +1997,14 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56)
cs35l56_dai, ARRAY_SIZE(cs35l56_dai));
if (ret < 0) {
dev_err_probe(cs35l56->base.dev, ret, "Register codec failed\n");
- goto err;
+ goto err_remove_wm_adsp;
}
return 0;
+err_remove_wm_adsp:
+ wm_adsp2_remove(&cs35l56->dsp);
+
err:
gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0);
regulator_bulk_disable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies);
@@ -2109,6 +2112,8 @@ void cs35l56_remove(struct cs35l56_private *cs35l56)
destroy_workqueue(cs35l56->dsp_wq);
+ wm_adsp2_remove(&cs35l56->dsp);
+
pm_runtime_dont_use_autosuspend(cs35l56->base.dev);
pm_runtime_suspend(cs35l56->base.dev);
pm_runtime_disable(cs35l56->base.dev);
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/2] ASoC: cs35l56: Cleanup if component_probe fails
2026-06-09 12:07 [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
2026-06-09 12:07 ` [PATCH 1/2] ASoC: cs35l56: Fix missing calls to wm_adsp2_remove() Richard Fitzgerald
@ 2026-06-09 12:07 ` Richard Fitzgerald
2026-06-09 13:02 ` [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
2 siblings, 0 replies; 6+ messages in thread
From: Richard Fitzgerald @ 2026-06-09 12:07 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
If cs35l56_component_probe() fails, call cs35l56_component_remove() to
clean up.
All the cleanup in cs35l56_component_remove() is the same cleanup that
would need to be done (at least partially) if cs35l56_component_probe()
fails. So calling cs35l56_component_remove() avoids convoluted cleanup
gotos and duplicated code in cs35l56_component_probe().
The only action in cs35l56_component_remove() that is nominally
dependent on having completed the component_probe() action is the call
to wm_adsp2_component_remove(). Though it is currently safe to call that
even if wm_adsp2_component_probe() was not called. However,
wm_adsp2_component_probe() has been trivially updated to check itself
whether it needs to cleanup.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e49611252900 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
---
sound/soc/codecs/cs35l56.c | 13 ++++++++++++-
sound/soc/codecs/wm_adsp.c | 7 +++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 5de9cf3d0330..6e2d92ab98e1 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -1359,7 +1359,7 @@ VISIBLE_IF_KUNIT int cs35l56_set_fw_name(struct snd_soc_component *component)
}
EXPORT_SYMBOL_IF_KUNIT(cs35l56_set_fw_name);
-static int cs35l56_component_probe(struct snd_soc_component *component)
+static int _cs35l56_component_probe(struct snd_soc_component *component)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
@@ -1459,6 +1459,17 @@ static void cs35l56_component_remove(struct snd_soc_component *component)
cs35l56->component = NULL;
}
+static int cs35l56_component_probe(struct snd_soc_component *component)
+{
+ int ret;
+
+ ret = _cs35l56_component_probe(component);
+ if (ret < 0)
+ cs35l56_component_remove(component);
+
+ return ret;
+}
+
static int cs35l56_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index ca630c9948e4..baa75e7ff53b 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1170,7 +1170,14 @@ EXPORT_SYMBOL_GPL(wm_adsp2_component_probe);
int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component)
{
+ if (!dsp)
+ return 0;
+
+ if (!dsp->component)
+ return 0;
+
cs_dsp_cleanup_debugfs(&dsp->cs_dsp);
+ dsp->component = NULL;
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks
2026-06-09 12:07 [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
2026-06-09 12:07 ` [PATCH 1/2] ASoC: cs35l56: Fix missing calls to wm_adsp2_remove() Richard Fitzgerald
2026-06-09 12:07 ` [PATCH 2/2] ASoC: cs35l56: Cleanup if component_probe fails Richard Fitzgerald
@ 2026-06-09 13:02 ` Richard Fitzgerald
2026-06-09 17:29 ` Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Richard Fitzgerald @ 2026-06-09 13:02 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
On 09/06/2026 1:07 pm, Richard Fitzgerald wrote:
> These are for-next.
>
> They are not urgent because it only leaks memory if the driver failed to
> component_probe or is removed, which wouldn't happen in normal use.
>
> These two patches fix some memory leaks:
> - The memory allocated by wm_adsp/cs_dsp was not freed.
> - If component_probe() failed it didn't clean up.
>
> Richard Fitzgerald (2):
> ASoC: cs35l56: Fix missing calls to wm_adsp2_remove()
> ASoC: cs35l56: Cleanup if component_probe fails
>
> sound/soc/codecs/cs35l56.c | 20 ++++++++++++++++++--
> sound/soc/codecs/wm_adsp.c | 7 +++++++
> 2 files changed, 25 insertions(+), 2 deletions(-)
>
Sashiko doesn't like these, so ignore them and I'll look at its
complaints and do a V2.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks
2026-06-09 13:02 ` [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks Richard Fitzgerald
@ 2026-06-09 17:29 ` Mark Brown
2026-06-10 8:38 ` Richard Fitzgerald
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2026-06-09 17:29 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 351 bytes --]
On Tue, Jun 09, 2026 at 02:02:51PM +0100, Richard Fitzgerald wrote:
> Sashiko doesn't like these, so ignore them and I'll look at its
> complaints and do a V2.
FWIW it's not gospel, and in particular if it's a preexisting issue
while it's obviously good to fix them I'm not going to block something
for it unless there's some really special reason.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] ASoC: cs35l56: Fix some cleanup memory leaks
2026-06-09 17:29 ` Mark Brown
@ 2026-06-10 8:38 ` Richard Fitzgerald
0 siblings, 0 replies; 6+ messages in thread
From: Richard Fitzgerald @ 2026-06-10 8:38 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, linux-kernel, patches
On 09/06/2026 6:29 pm, Mark Brown wrote:
> On Tue, Jun 09, 2026 at 02:02:51PM +0100, Richard Fitzgerald wrote:
>
>> Sashiko doesn't like these, so ignore them and I'll look at its
>> complaints and do a V2.
>
> FWIW it's not gospel, and in particular if it's a preexisting issue
> while it's obviously good to fix them I'm not going to block something
> for it unless there's some really special reason.
I know, and it depends which AI engine Sashiko chooses. But I like to
take the time to be sure there isn't something real hiding in apparently
bogus reports.
^ permalink raw reply [flat|nested] 6+ messages in thread