Re: [PATCH v2 2/2] ASoC: fsl: imx-card: initialize playback_only and capture_only
From: Kuninori Morimoto
Date: Tue Mar 17 2026 - 19:18:49 EST
Hi
> > Fix uninitialized variable playback_only and capture_only because
> > graph_util_parse_link_direction() may not write them.
>
> > @@ -544,7 +544,7 @@ static int imx_card_parse_of(struct imx_card_data *data)
> > struct snd_soc_dai_link *link;
> > struct dai_link_data *link_data;
> > struct of_phandle_args args;
> > - bool playback_only, capture_only;
> > + bool playback_only = false, capture_only = false;
>
> Don't we need to initalise these once per link rather than once for the
> whole function, otherwise if they are initialised one time then any
> subsequent links will inherit the new value?
Ah, yes indeed. It is called under for_each loop.
So we need is...
------- 8< ------- 8< ------- 8< ------- 8< ------- 8< ------- 8< -------
diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 05b4e971a3661..a4518fefad690 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -710,6 +710,8 @@ static int imx_card_parse_of(struct imx_card_data *data)
link->ops = &imx_aif_ops;
}
+ playback_only = false;
+ capture_only = false;
graph_util_parse_link_direction(np, &playback_only, &capture_only);
link->playback_only = playback_only;
link->capture_only = capture_only;
Thank you for your help !!
Best regards
---
Kuninori Morimoto