[PATCH 2/2] ASoC: spacemit: init *dp to NULL before error paths
[email protected] Fri, 31 Jul 2026 17:15:39 +0700
| Newsgroups | dev.linux.lists.spacemit,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
From: bui duc phuc <[email protected]> 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 <[email protected]> --- 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