ASoC: mc13783: Ensure we only try to dereference valid of_nodes
authorMark Brown <broonie@kernel.org>
Wed, 8 Oct 2014 14:31:18 +0000 (15:31 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 8 Oct 2014 14:42:33 +0000 (15:42 +0100)
Reported-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/mc13783.c

index 388f90a597fa0ea31a608351ee99233bc2d3fc68..71f775aad7c715f18b3ebdd16b385bb5501de5eb 100644 (file)
@@ -765,12 +765,18 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
                        return -ENOSYS;
 
                ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port);
-               if (ret)
-                       goto out;
+               if (ret) {
+                       of_node_put(np);
+                       return ret;
+               }
 
                ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port);
-               if (ret)
-                       goto out;
+               if (ret) {
+                       of_node_put(np);
+                       return ret;
+               }
+
+               of_node_put(np);
        }
 
        dev_set_drvdata(&pdev->dev, priv);
@@ -783,8 +789,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
                ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783,
                        mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async));
 
-out:
-       of_node_put(np);
        return ret;
 }