From patchwork Tue Oct 7 18:14:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5048321 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 673B2C11AB for ; Tue, 7 Oct 2014 18:15:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C49A8201F5 for ; Tue, 7 Oct 2014 18:15:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 86F07201F4 for ; Tue, 7 Oct 2014 18:15:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B6DE52606F7; Tue, 7 Oct 2014 20:15:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C4DF22604D0; Tue, 7 Oct 2014 20:14:09 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A60C2260697; Tue, 7 Oct 2014 20:14:08 +0200 (CEST) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B44582604D0 for ; Tue, 7 Oct 2014 20:14:00 +0200 (CEST) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 93F78AD95; Tue, 7 Oct 2014 18:14:00 +0000 (UTC) Date: Tue, 07 Oct 2014 20:14:00 +0200 Message-ID: From: Takashi Iwai To: Mark Brown In-Reply-To: <20141007180434.GU4609@sirena.org.uk> References: <1412698794-25536-1-git-send-email-tiwai@suse.de> <1412698794-25536-2-git-send-email-tiwai@suse.de> <20141007170938.GM4609@sirena.org.uk> <20141007172337.GR4609@sirena.org.uk> <20141007180434.GU4609@sirena.org.uk> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.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 X-Virus-Scanned: ClamAV using ClamSMTP At Tue, 7 Oct 2014 19:04:34 +0100, Mark Brown wrote: > > On Tue, Oct 07, 2014 at 07:39:03PM +0200, Takashi Iwai wrote: > > Mark Brown wrote: > > > > Well, in this case I'd just move the of_node_put() into the existing > > > check for pdata since we don't ever reference np outside of that anyway. > > > Yeah, that's an option, too, but it'd make the code less readable. > > So I chose the straightforward way. > > I don't actually see it as a readability concern - to me having the get > and release close to each other and especially having them at the same > level of indentation helps. I do understand the merit, but it looks uglier to my taste. The success path goes again with if (ret). (Or we'd need two goto's or deeper if-else blocks.) Takashi diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 388f90a597fa..cffbf09ba67c 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -749,7 +749,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) { struct mc13783_priv *priv; struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data; - struct device_node *np; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); @@ -760,6 +759,8 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) priv->adc_ssi_port = pdata->adc_ssi_port; priv->dac_ssi_port = pdata->dac_ssi_port; } else { + struct device_node *np; + np = of_get_child_by_name(pdev->dev.parent->of_node, "codec"); if (!np) return -ENOSYS; @@ -771,6 +772,10 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port); if (ret) goto out; + out: + of_node_put(np); + if (ret) + return ret; } dev_set_drvdata(&pdev->dev, priv); @@ -783,8 +788,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; }