ASoC: meson: axg-card: fix null pointer dereference in clean up
Hello Jerome Brunet,
The patch 960f428ca0a0: "ASoC: meson: axg-card: fix null pointer dereference in clean up" from Jun 10, 2019, leads to the following static checker warning:
sound/soc/meson/axg-card.c:121 axg_card_clean_references() warn: address of 'link->codecs[j]' is non-NULL
sound/soc/meson/axg-card.c
109 static void axg_card_clean_references(struct axg_card *priv) 110 {
111 struct snd_soc_card *card = &priv->card;
112 struct snd_soc_dai_link *link;
113 struct snd_soc_dai_link_component *codec;
114 int i, j;
115
116 if (card->dai_link) {
117 for_each_card_prelinks(card, i, link) {
118 if (link->cpus)
119 of_node_put(link->cpus->of_node);
120 for_each_link_codecs(link, j, codec)
121 if (codec)
^^^^^"codec" is the list iterator so it can't possibly be NULL.
122 of_node_put(codec->of_node);
123 }
124 }
125
126 if (card->aux_dev) {
127 for (i = 0; i < card->num_aux_devs; i++)
128 of_node_put(card->aux_dev[i].codec_of_node);
129 }
130
131 kfree(card->dai_link);
132 kfree(priv->link_data);
133 }regards,
dan carpenter
Quoted 24 lines · Dan Carpenter
Hello Jerome Brunet,
The patch
960f428ca0a0: "ASoC: meson: axg-card: fix null pointer dereference in clean up" from Jun 10, 2019, leads to the following static checker warning:sound/soc/meson/axg-card.c:121 axg_card_clean_references() warn: address of 'link->codecs[j]' is non-NULL
sound/soc/meson/axg-card.c
109 static voidaxg_card_clean_references(struct axg_card *priv)110 { 111 struct snd_soc_card *card = &priv->card; 112 struct snd_soc_dai_link *link; 113 struct snd_soc_dai_link_component *codec; 114 int i, j; 115 116 if (card->dai_link) { 117 for_each_card_prelinks(card, i, link) { 118 if (link->cpus) 119 of_node_put(link->cpus->of_node); 120 for_each_link_codecs(link, j, codec) 121 if (codec) ^^^^^
Quoted 1 line
"codec" is the list iterator so it can't possibly be NULL.
Indeed, only "cpus" need a check.
Thanks for reporting this Dan
I'll post a fixup soon
Quoted 16 lines
122 of_node_put(codec->of_node); 123 } 124 } 125 126 if (card->aux_dev) { 127 for (i = 0; i < card->num_aux_devs; i++) 128 of_node_put(card->aux_dev[i].codec_of_node); 129 } 130 131 kfree(card->dai_link); 132 kfree(priv->link_data); 133 }regards,
dan carpenter