[PATCH] ASoC: qcom: qdsp6: Fix device node leaks when parsing "iommus" phandle
From: zhaofeng2
Date: Tue Nov 10 2026 - 06:52:38 EST
From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
q6asm_dai_probe(), q6apm_dai_probe() and q6usb_dai_dev_probe() parse
the "iommus" phandle with of_parse_phandle_with_fixed_args(), which
takes a reference on the iommu device node, but none of them drops
the reference after the stream ID has been read from args.args[0],
so the iommu node is leaked on every probe.
Drop the reference with of_node_put() after reading args.args[0].
This is a refreshed version of the fix posted by Selby Mashiki [1],
which no longer applies because the context in q6apm_dai_probe() has
changed since; the leaks are still present in all three functions.
Originally-by: Selby Mashiki <mashikiselby@xxxxxxxxx>
Link: https://lore.kernel.org/linux-sound/20261025190340.449613-1-mashikiselby@xxxxxxxxx/ [1]
Fixes: 2a9e92d371db ("ASoC: qdsp6: q6asm: Add q6asm dai driver")
Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support")
Fixes: 72b0b8b29980 ("ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6")
Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
---
sound/soc/qcom/qdsp6/q6apm-dai.c | 4 +++-
sound/soc/qcom/qdsp6/q6asm-dai.c | 4 +++-
sound/soc/qcom/qdsp6/q6usb.c | 4 +++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -1203,8 +1203,10 @@
rc = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
if (rc < 0)
pdata->sid = -1;
- else
+ else {
pdata->sid = args.args[0] & SID_MASK_DEFAULT;
+ of_node_put(args.np);
+ }
if (apm && apm->gdev &&
apm->gdev->domain_id == GPR_DOMAIN_ID_MODEM) {
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -1309,8 +1309,10 @@
rc = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
if (rc < 0)
pdata->sid = -1;
- else
+ else {
pdata->sid = args.args[0] & SID_MASK_DEFAULT;
+ of_node_put(args.np);
+ }
dev_set_drvdata(dev, pdata);
diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
--- a/sound/soc/qcom/qdsp6/q6usb.c
+++ b/sound/soc/qcom/qdsp6/q6usb.c
@@ -382,8 +382,10 @@
}
ret = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
- if (!ret)
+ if (!ret) {
data->priv.sid = args.args[0] & Q6_USB_SID_MASK;
+ of_node_put(args.np);
+ }
ret = devm_mutex_init(dev, &data->mutex);
if (ret < 0)