Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2656375imm; Sun, 17 Jun 2018 01:06:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKN8pSJMc49Qw4nn+X2zsiSZYdgHqsWmwI1Pj1w7ompobD54GqjNXA9dWHRXfiJ+T470i2p X-Received: by 2002:a62:8d5:: with SMTP id 82-v6mr8930002pfi.154.1529222760081; Sun, 17 Jun 2018 01:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529222760; cv=none; d=google.com; s=arc-20160816; b=KFBTiVC0xeyT+ea1VXJqcNpUq82Nrrhi5YMg895egMq3pRJT2+uYlhYqJxtV6m/LWs hLcwl4EUfzbcshr8KrwZUxrKp/2ABhs4QNfG4uO+Q77ev5REEJiDdZzaEbyFQe6r02jQ EHweGQLTEkf3UKn6CWjqN/H7AclGATMrS4KDiTJaizlE1tex4uzv/cWPBlG9f2INu9nl APeFLGreQCQ7GPfkWIv264ttm6yMXWz1Neemprka2AsqRCYWSo80bsopNp+Q135g2GjJ kJlxcYwzPTScbmOZTrDD0Sd9voOjtzmweqiRzPyM7x/Tf7hRAhZVTuxULvN5WCr2UOJP 4ZwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=kQke9Xv9Bpj6JD2C7FASPx9OI8YVpNr+MCVuGjEAUt0=; b=QtkUiv4tiCTh967fy1I/PP/QLZbtpNUVxIGzXcUjfaL+6zHWdMKVMyzELg+F5smAR6 tooe67hAL6FHwqjUO6IKOH+6Zur5UyEuTpPm4gu8TkBdnPSGJHgHvtaWqrv/l03z+5/G MpMjEBf75ibK1FkkPqO9IVr/yDV1OaB5TfYtOjTR/6/D1fC1xZBr33NtCnAwzfnNSZZL aOSRx0Aa4jvtNJO8UOf9f6/ShPJJ5TN4bi/AZFHTjbINGrlIV7w9CgC3BTUNoq4yrpgP Yy64u78+9dfEBl/0E+wmCRYM68b9o8Nn9BapcmWAPLSnguY8hrFbWl83Ul3QPz3XV48i Qr/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24-v6si12236303pfk.276.2018.06.17.01.05.45; Sun, 17 Jun 2018 01:06:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932690AbeFQIEI (ORCPT + 99 others); Sun, 17 Jun 2018 04:04:08 -0400 Received: from 178.115.242.59.static.drei.at ([178.115.242.59]:60930 "EHLO mail.osadl.at" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S932451AbeFQIEG (ORCPT ); Sun, 17 Jun 2018 04:04:06 -0400 Received: by mail.osadl.at (Postfix, from userid 1001) id BCCB65C098D; Sun, 17 Jun 2018 08:02:42 +0000 (UTC) Date: Sun, 17 Jun 2018 08:02:42 +0000 From: Nicholas Mc Guire To: Alexey Khoroshilov Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , ldv-project@linuxtesting.org, alsa-devel@alsa-project.org, sil2review@lists.osadl.org, linux-kernel@vger.kernel.org, Julia Lawall , linux-tegra@vger.kernel.org Subject: Re: [SIL2review] [PATCH] ASoC: tegra: fix device_node refcounting Message-ID: <20180617080242.GB24046@osadl.at> References: <1529101378-5543-1-git-send-email-khoroshilov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1529101378-5543-1-git-send-email-khoroshilov@ispras.ru> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 16, 2018 at 01:22:58AM +0300, Alexey Khoroshilov wrote: > tegra_rt5677_probe() gets a couple of device nodes with of_parse_phandle(), > but there is no release of them. > > The patch adds the release to tegra_rt5677_remove() and > to error handling paths in the probe. > > Found by Linux Driver Verification project (linuxtesting.org). static int tegra_rt5677_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; calls of_get_named_gpio() three times and then checks for -EPROBE_DEFER and bails out in that error cases. but of_get_named_gpio() may have incremented np at that point. The call try i think is: of_get_named_gpio(np,....) -> of_get_named_gpio_flags() -> of_get_named_gpiod_flags() -> of_parse_phandle_with_args_map() -> of_for_each_phandle() -> of_phandle_iterator_next() -> of_find_node_by_phandle() -> of_node_get(np) so that got refcounted as well and not decremented/released in the non -EPROBE_DEFER case. I think those should be added while cleaning up the other missing of_node_put() you detected below. I think thos of_node_put() are also missing. > > Signed-off-by: Alexey Khoroshilov Reviewed-by: Nicholas Mc Guire > --- > sound/soc/tegra/tegra_rt5677.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c > index 0e4805c7b4ca..7081f15302cc 100644 > --- a/sound/soc/tegra/tegra_rt5677.c > +++ b/sound/soc/tegra/tegra_rt5677.c > @@ -264,13 +264,13 @@ static int tegra_rt5677_probe(struct platform_device *pdev) > dev_err(&pdev->dev, > "Property 'nvidia,i2s-controller' missing or invalid\n"); > ret = -EINVAL; > - goto err; > + goto err_put_codec_of_node; > } > tegra_rt5677_dai.platform_of_node = tegra_rt5677_dai.cpu_of_node; > > ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); > if (ret) > - goto err; > + goto err_put_cpu_of_node; > > ret = snd_soc_register_card(card); > if (ret) { > @@ -283,6 +283,13 @@ static int tegra_rt5677_probe(struct platform_device *pdev) > > err_fini_utils: > tegra_asoc_utils_fini(&machine->util_data); > +err_put_cpu_of_node: > + of_node_put(tegra_rt5677_dai.cpu_of_node); > + tegra_rt5677_dai.cpu_of_node = NULL; > + tegra_rt5677_dai.platform_of_node = NULL; > +err_put_codec_of_node: > + of_node_put(tegra_rt5677_dai.codec_of_node); > + tegra_rt5677_dai.codec_of_node = NULL; > err: > return ret; > } > @@ -296,6 +303,12 @@ static int tegra_rt5677_remove(struct platform_device *pdev) > > tegra_asoc_utils_fini(&machine->util_data); > > + tegra_rt5677_dai.platform_of_node = NULL; > + of_node_put(tegra_rt5677_dai.codec_of_node); > + tegra_rt5677_dai.codec_of_node = NULL; > + of_node_put(tegra_rt5677_dai.cpu_of_node); > + tegra_rt5677_dai.cpu_of_node = NULL; > + > return 0; > } > > -- > 2.7.4 > > _______________________________________________ > SIL2review mailing list > SIL2review@lists.osadl.org > https://lists.osadl.org/mailman/listinfo/sil2review