From: Takashi Iwai Subject: Re: [PATCH] ASoC: mc13783: Ensure we only try to dereference valid of_nodes Date: Wed, 08 Oct 2014 17:06:15 +0200 Message-ID: References: <1412779204-30876-1-git-send-email-broonie@kernel.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B4EC426046F for ; Wed, 8 Oct 2014 17:06:18 +0200 (CEST) In-Reply-To: <1412779204-30876-1-git-send-email-broonie@kernel.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org, Liam Girdwood List-Id: alsa-devel@alsa-project.org At Wed, 8 Oct 2014 15:40:04 +0100, Mark Brown wrote: > > Reported-by: Takashi Iwai > Signed-off-by: Mark Brown > --- > sound/soc/codecs/mc13783.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c > index 388f90a597fa..71f775aad7c7 100644 > --- a/sound/soc/codecs/mc13783.c > +++ b/sound/soc/codecs/mc13783.c > @@ -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; > } I'd move the declaration of np into if block, too, so that it won't be referred in other places. thanks, Takashi