ASoC: samsung: odroid: Prevent uninitialized variable use
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Thu, 21 Feb 2019 09:42:28 +0000 (10:42 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 21 Feb 2019 11:39:00 +0000 (11:39 +0000)
This addresses an issue pointed out by compiler warning:

sound/soc/samsung/odroid.c: In function ‘odroid_audio_probe’:
sound/soc/samsung/odroid.c:298:22: warning: ‘cpu_dai’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  priv->clk_i2s_bus = of_clk_get_by_name(cpu_dai, "iis");
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/samsung/odroid.c

index c3b0f6c612cb31ef1be63ae10980dec6a0dacf7c..694512f980fdc207577fcd2a5a59d7a6484bfdd0 100644 (file)
@@ -194,7 +194,8 @@ static struct snd_soc_dai_link odroid_card_dais[] = {
 static int odroid_audio_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *cpu, *cpu_dai, *codec;
+       struct device_node *cpu_dai = NULL;
+       struct device_node *cpu, *codec;
        struct odroid_priv *priv;
        struct snd_soc_card *card;
        struct snd_soc_dai_link *link, *codec_link;
@@ -271,8 +272,11 @@ static int odroid_audio_probe(struct platform_device *pdev)
                if (ret < 0)
                        break;
        }
-       if (ret == 0)
+       if (ret == 0) {
                cpu_dai = of_parse_phandle(cpu, "sound-dai", 0);
+               if (!cpu_dai)
+                       ret = -EINVAL;
+       }
 
        of_node_put(cpu);
        of_node_put(codec);