[PATCH 2/2] ASoC: spacemit: init *dp to NULL before error paths
phucduc.bui at gmail.com
phucduc.bui at gmail.com
Fri Jul 31 03:15:39 PDT 2026
From: bui duc phuc <phucduc.bui at gmail.com>
spacemit_i2s_init_dai() takes an optional output parameter dp, but only
assigns *dp on the success path. If devm_kmemdup() fails, *dp is left
untouched.
The current caller does check the return value before using dp, so this
isn't an active bug. Still, initialize *dp to NULL upfront as a defensive
measure, consistent with how core helpers like _snd_pcm_new() handle
their optional output parameters.
Signed-off-by: bui duc phuc <phucduc.bui at gmail.com>
---
sound/soc/spacemit/k1_i2s.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/spacemit/k1_i2s.c b/sound/soc/spacemit/k1_i2s.c
index 64510c9a1a89..23037fa4233c 100644
--- a/sound/soc/spacemit/k1_i2s.c
+++ b/sound/soc/spacemit/k1_i2s.c
@@ -382,6 +382,9 @@ static int spacemit_i2s_init_dai(struct spacemit_i2s_dev *i2s,
struct property *dma_names;
const char *dma_name;
+ if (dp)
+ *dp = NULL;
+
of_property_for_each_string(node, "dma-names", dma_names, dma_name) {
if (!strcmp(dma_name, "tx"))
i2s->has_playback = true;
--
2.43.0
More information about the linux-riscv
mailing list