[PATCH] ASoC: imx-audmix: Balance SAI node references with devres
From: Zhu Jun
Date: Thu Nov 19 2026 - 02:58:45 EST
Each successful parse of a SAI phandle in imx_audmix_probe() takes
a node reference. The card uses these nodes in the DAI links and
codec configuration, but neither probe failure nor device removal
releases the references.
Register a devres action for each reference as soon as it is acquired.
The card registration is managed by the same device, so the actions
release the nodes after the card has been unregistered.
Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
sound/soc/fsl/imx-audmix.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
index 2372cd26ee47..8d7faa1b9cc3 100644
--- a/sound/soc/fsl/imx-audmix.c
+++ b/sound/soc/fsl/imx-audmix.c
@@ -10,6 +10,7 @@
* https://www.gnu.org/copyleft/gpl.html
*/
+#include <linux/device/devres.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/clk.h>
@@ -123,6 +124,11 @@ static const char *name[][3] = {
{"SAI-Playback", "SAI-Playback", "AUDMIX-Capture-0"},
};
+static void imx_audmix_put_node(void *data)
+{
+ of_node_put(data);
+}
+
static int imx_audmix_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -206,6 +212,11 @@ static int imx_audmix_probe(struct platform_device *pdev)
return ret;
}
+ ret = devm_add_action_or_reset(&pdev->dev, imx_audmix_put_node,
+ args.np);
+ if (ret)
+ return ret;
+
cpu_pdev = of_find_device_by_node(args.np);
if (!cpu_pdev) {
dev_err(&pdev->dev, "failed to find SAI platform device\n");