Re: [PATCH] ASoC: meson: aiu: Fix resource leak
From: Valerio Setti
Date: Tue Jul 07 2026 - 16:34:18 EST
On 7/7/26 3:24 AM, Ethan Tidmore wrote:
In snd_soc_register_component() error path, the aiu-formatter is not
being freed. Instead of returning now goto the err tag so the
aiu-formatter can properly be freed.
Fixes: 83b83024cdbfd ("ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data")
Signed-off-by: Ethan Tidmore <ethantidmore06@xxxxxxxxx>
---
sound/soc/meson/aiu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/meson/aiu.c b/sound/soc/meson/aiu.c
index 64ace4d25d92..d6b644a53f7e 100644
--- a/sound/soc/meson/aiu.c
+++ b/sound/soc/meson/aiu.c
@@ -310,7 +310,7 @@ static int aiu_probe(struct platform_device *pdev)
ARRAY_SIZE(aiu_cpu_dai_drv));
if (ret) {
dev_err(dev, "Failed to register cpu component\n");
- return ret;
+ goto err;
}
/* Register the hdmi codec control component */
Technically the fix is OK, but I don't think the commit title and message are correct. aiu-formatter data is allocated in 'gx_formatter_create' using 'devm_kzalloc' so, unless I'm missing something, the data should be automatically freed when the device is removed in case of error.
What 'gx_formatter_free' does is simply clearing widget's private pointer (i.e. 'w->priv'). I think that not clearing it should not have any bad consequence since the pointer would be overwritten on the next probe. However I agree that for consistency reasons it's a good thing to clear to do when 'aiu_probe' fails.
So perhaps the title should be rewritten to something like "ASoC: meson: aiu: reset widget private data on probe error path"?
--
Valerio