ASoC: mc13783: Ensure we only try to dereference valid of_nodes
Mark Brown
maintainerPATCH 1/1 ASoC: mc13783: Ensure we only try to dereference valid of_nodes
--- sound/soc/codecs/mc13783.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/codecs/mc13783.c +10 -6
@@ -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; }
Signature · 1 line
2.1.1
At Wed, 8 Oct 2014 15:40:04 +0100,
Quoted 35 lines · Mark Brown
Reported-by Takashi Iwai <[email protected]>Signed-off-by Mark Brown <[email protected]>--- sound/soc/codecs/mc13783.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)sound/soc/codecs/mc13783.c +10
-4@@ -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);
sound/soc/codecs/mc13783.c static int __init mc13783_codec_probe(struct platform_device *pdev) · line 793
Quoted 7 lines
sound/soc/codecs/mc13783.c +0
-2@@ -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; }
I'd move the declaration of np into if block, too, so that it won't be referred in other places.
thanks,
Takashi
Mark Brown
maintainerQuoted 2 lines · Takashi Iwai
I'd move the declaration of np into if block, too, so that it won't be referred in other places.
I generally dislike that style outside of very large functions; it's not typical for C.
At Wed, 8 Oct 2014 16:50:15 +0100,
Quoted 8 lines · Mark Brown
Quoted 2 lines · Takashi Iwai
I'd move the declaration of np into if block, too, so that it won't be referred in other places.
I generally dislike that style outside of very large functions; it's not typical for C.
OK, it's a matter of taste. A typical bikeshed topic, we can spend hours about this :)
Takashi