Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1369992img; Tue, 26 Feb 2019 20:41:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbxjewG/aiJuw2Jtnx8iCYEwuLjuV77YqIOtDsPm6K6vYs4hZ/GjZYDuQ1WzvjXsxC3sI48 X-Received: by 2002:a63:c204:: with SMTP id b4mr1074289pgd.335.1551242512009; Tue, 26 Feb 2019 20:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551242512; cv=none; d=google.com; s=arc-20160816; b=SYZr1NkCdvzwQoqJZZ8c8Se3gNfO9KaLtkTXIpoI+Gh2LOLPtxccWfxowVwx2dCs0v WDtpESUlZJRshwzBoAN/nN0qtYYWKh5OKamxg4boY/r3eGnDmjyajqpJ4DxI8QArHIoT e9dtNe8dSPYsHhj1exRNQaCXSdCkp9oXIwrVubldMIkd6gWhRUAEFsF+iCjJvjE0nPg9 KKWOXGk8HJO9ETMLGZ8CWXMbsMHn+YRYq/5tPJc2h57Tp2EGJn7ThUNjAOAtMTJ/1kqK /G257UhRLl3g8TPnFKpvpJ5pZty2SjWdsLIYE3yeM+/azqoxZB7p+kCb21o2Kt9rkGC9 xzoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Zl0bc+bycM6tFvAXfg0wP6PwwxSRB+oHCm3mQaay8MI=; b=OeUJQKaNtRn/mMlSILxUg3aHA0seSo45gR93TMDtL5l0AVcUaFkFDHdSKTFxtQJlG1 2OWUsaVm4P/+Ed86005MLfZVMbWvDwjRcF/rsSKW1+b+N65UuTf+V3yt/k90NZw69al8 kyajcygpY3CTLDgcZJ6AiTYGOERZgFbzbS4xEwhbvneIATUEmkY4Fog4k3LJ788uQbfC O6RzkJ3dXtY8AqpRFjt/dmpSbPFrEduA6uza8HPYY2eq9HFBBbPfDByJ1wSanVtNA7E/ KwYsKFT1/Ube5ESejdYqr4KrcJjhxOINESaP57AGlqjlHKuOVOa5vQ8Xqu4iGjxw2L9a jhQA== 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 s9si14670212pgm.133.2019.02.26.20.41.36; Tue, 26 Feb 2019 20:41:51 -0800 (PST) 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 S1729734AbfB0Ekz (ORCPT + 99 others); Tue, 26 Feb 2019 23:40:55 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:33144 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729435AbfB0Ekx (ORCPT ); Tue, 26 Feb 2019 23:40:53 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 7D76CE85EDBE605184E3; Wed, 27 Feb 2019 12:40:42 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1R4eaTr003644; Wed, 27 Feb 2019 12:40:36 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019022712405722-2029107 ; Wed, 27 Feb 2019 12:40:57 +0800 From: Wen Yang To: benh@kernel.crashing.org Cc: paulus@samba.org, mpe@ellerman.id.au, tyreld@linux.vnet.ibm.com, bhelgaas@google.com, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ryder.lee@mediatek.com, lorenzo.pieralisi@arm.com, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, rjui@broadcom.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, thomas.petazzoni@bootlin.com, shawn.lin@rock-chips.com, heiko@sntech.de, linux-rockchip@lists.infradead.org, minghuan.Lian@nxp.com, mingkai.hu@nxp.com, roy.zang@nxp.com, hayashi.kunihiko@socionext.com, yamada.masahiro@socionext.com, kishon@ti.com, linux-omap@vger.kernel.org, wang.yi59@zte.com.cn, Wen Yang Subject: [PATCH 2/8] PCI: uniphier: fix a leaked reference by adding missing of_node_put Date: Wed, 27 Feb 2019 12:40:37 +0800 Message-Id: <1551242443-27300-2-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551242443-27300-1-git-send-email-wen.yang99@zte.com.cn> References: <1551242443-27300-1-git-send-email-wen.yang99@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-02-27 12:40:57, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-27 12:40:29, Serialize complete at 2019-02-27 12:40:29 X-MAIL: mse01.zte.com.cn x1R4eaTr003644 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/dwc/pcie-uniphier.c:283:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. ./drivers/pci/controller/dwc/pcie-uniphier.c:290:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. ./drivers/pci/controller/dwc/pcie-uniphier.c:296:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Kunihiko Hayashi Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Masahiro Yamada Cc: linux-pci@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pci/controller/dwc/pcie-uniphier.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-uniphier.c b/drivers/pci/controller/dwc/pcie-uniphier.c index d5dc402..3f30ee4 100644 --- a/drivers/pci/controller/dwc/pcie-uniphier.c +++ b/drivers/pci/controller/dwc/pcie-uniphier.c @@ -270,6 +270,7 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); struct device_node *np = pci->dev->of_node; struct device_node *np_intc; + int ret = 0; np_intc = of_get_child_by_name(np, "legacy-interrupt-controller"); if (!np_intc) { @@ -280,20 +281,24 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) pp->irq = irq_of_parse_and_map(np_intc, 0); if (!pp->irq) { dev_err(pci->dev, "Failed to get an IRQ entry in legacy-interrupt-controller\n"); - return -EINVAL; + ret = -EINVAL; + goto out_put_node; } priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, &uniphier_intx_domain_ops, pp); if (!priv->legacy_irq_domain) { dev_err(pci->dev, "Failed to get INTx domain\n"); - return -ENODEV; + ret = -ENODEV; + goto out_put_node; } irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler, pp); - return 0; +out_put_node: + of_node_put(np_intc); + return ret; } static int uniphier_pcie_host_init(struct pcie_port *pp) -- 2.9.5