Re: [PATCH v2 2/2] ASoC: fsl: imx-card: initialize playback_only and capture_only

From: Shengjiu Wang

Date: Tue Mar 17 2026 - 22:05:27 EST


On Wed, Mar 18, 2026 at 7:18 AM Kuninori Morimoto
<kuninori.morimoto.gx@xxxxxxxxxxx> wrote:
>
>
> 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;

This one may be better. thanks.
I will update it.

best regards
shengjiu wang
>
>
>
>
>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto
>