Re: [bug report] ASoC: loongson: Add Loongson ASoC Sound Card Support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi dan,

You are right, snd_soc_of_get_dai_name() can fail, we should check its
return value.

I noticed that Kuninori Morimoto's patch removed this part of code.
please refer to link:
https://lore.kernel.org/alsa-devel/87352ndmlq.wl-kuninori.morimoto.gx@xxxxxxxxxxx/

As broonie's comments, the patch will be merged soon. If the patch is not merged
in the end, i will add a new patch to fix.

Thanks,
Yingkun

On 2023/6/19 17:45, Dan Carpenter wrote:
Hello Yingkun Meng,

The patch d24028606e76: "ASoC: loongson: Add Loongson ASoC Sound Card
Support" from Jun 14, 2023, leads to the following Smatch static
checker warning:

   sound/soc/loongson/loongson_card.c:157 loongson_card_parse_of()
   error: uninitialized symbol 'cpu_dai_name'.

   sound/soc/loongson/loongson_card.c:158 loongson_card_parse_of()
   error: uninitialized symbol 'codec_dai_name'.

sound/soc/loongson/loongson_card.c
     115 static int loongson_card_parse_of(struct loongson_card_data *data)
     116 {
     117         const char *cpu_dai_name, *codec_dai_name;
     118         struct device_node *cpu, *codec;
     119         struct snd_soc_card *card = &data->snd_card;
     120         struct device *dev = card->dev;
     121         struct of_phandle_args args;
     122         int ret, i;
     123
     124         cpu = of_get_child_by_name(dev->of_node, "cpu");
     125         if (!cpu) {
     126                 dev_err(dev, "platform property missing or invalid\n");
     127                 return -EINVAL;
     128         }
     129         codec = of_get_child_by_name(dev->of_node, "codec");
     130         if (!codec) {
     131                 dev_err(dev, "audio-codec property missing or invalid\n");
     132                 ret = -EINVAL;
     133                 goto err;
     134         }
     135
     136         ret = of_parse_phandle_with_args(cpu, "sound-dai",
     137                                          "#sound-dai-cells", 0, &args);
     138         if (ret) {
     139                 dev_err(dev, "codec node missing #sound-dai-cells\n");
     140                 goto err;
     141         }
     142         for (i = 0; i < card->num_links; i++)
     143                 loongson_dai_links[i].cpus->of_node = args.np;
     144
     145         ret = of_parse_phandle_with_args(codec, "sound-dai",
     146                                          "#sound-dai-cells", 0, &args);
     147         if (ret) {
     148                 dev_err(dev, "codec node missing #sound-dai-cells\n");
     149                 goto err;
     150         }
     151         for (i = 0; i < card->num_links; i++)
     152                 loongson_dai_links[i].codecs->of_node = args.np;
     153
     154         snd_soc_of_get_dai_name(cpu, &cpu_dai_name);
     155         snd_soc_of_get_dai_name(codec, &codec_dai_name);

It looks like snd_soc_of_get_dai_name() can fail but I can add an
exception for that if it never fails in real life.

     156         for (i = 0; i < card->num_links; i++) {
--> 157                 loongson_dai_links[i].cpus->dai_name = cpu_dai_name;
     158                 loongson_dai_links[i].codecs->dai_name = codec_dai_name;
     159         }
     160         of_node_put(cpu);
     161         of_node_put(codec);
     162
     163         return 0;
     164
     165 err:
     166         of_node_put(cpu);
     167         of_node_put(codec);
     168         return ret;
     169 }

regards,
dan carpenter




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux