Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1369893img; Tue, 26 Feb 2019 20:41:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IYqdKlVuqHAgjgS/U8pvB7dnsCTeFyxb5GwwD1W34sVdGJr1xM2Jo0Vz4DJ6FpJacCwRkMY X-Received: by 2002:aa7:924e:: with SMTP id 14mr30196248pfp.30.1551242500614; Tue, 26 Feb 2019 20:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551242500; cv=none; d=google.com; s=arc-20160816; b=LIwk1jj4SUR+W4Ey0Q4r1fCqKIKhwh2f1mmSd57mWiIjF5RNyRHJ7H1ke/M7nrRt+l 96sZIpwSRhDlSwOIzxgLN6Z2SJlGJQambUiFsSMnZEZeIq+GRt1g8PeGW6SrSHjRS9aM u05nO2rOD85hwpHWVXf6zymRsxNA8mmEyzel6yGhtZPJ3kCgzlwYRTrLPfbF4MHSud2o srxXLpposZBmlSaOEKylF6Mp1pkvJRK+m+G30RSXsvco0jdL2FGhJWa6jySKEPL+ltVa sg25ZgK2IByMcdiV1Oz3vluN106nzFVFjIyWTN98HbKn29nVfTL/6LXtnj5yjZfbonqG JHEQ== 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=AfoP0Vix1suurqouHotDZxrnBEzZ6DVV43Jp200GTlk=; b=PgN3cTM8DBp2HcGItqESfkpmBX1t3ljTToI3vnnRFYNhw2b8vraAnHgSrhkHC4Ij/J ESCs/AIoOnDzKTDLIpDKZ4FEwGILNI47TkFIblQFS9plDzelieKUsBDQw7SrOxu/qJ7n R38bqBrqabun+JtsnbYbJJCbUfxK5iNlmMqJCz/PthyTGZ9Vt7x2XzQFzhGg0T1wTlpL XIla+YRyxzaKK9a+WXsWIncom7pYpvASJ/3E+ztho01xw2ZfDUxu/n3jzJx94waCYbiW AvKvCYr6m4mcVBfJTzzlDui7wBf4bBrMw4nQvNi8DHbrL03PWmuz04DdI2D7xE32AKDz 1W0g== 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 15si14438101pfq.11.2019.02.26.20.41.26; Tue, 26 Feb 2019 20:41:40 -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 S1729768AbfB0Ek5 (ORCPT + 99 others); Tue, 26 Feb 2019 23:40:57 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:33394 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729674AbfB0Ek4 (ORCPT ); Tue, 26 Feb 2019 23:40:56 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 69CC474E1EE0FF3A0483; Wed, 27 Feb 2019 12:40:53 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1R4em8h003706; Wed, 27 Feb 2019 12:40:48 +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 2019022712410885-2029139 ; Wed, 27 Feb 2019 12:41:08 +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 5/8] PCI: aardvark: fix a leaked reference by adding missing of_node_put Date: Wed, 27 Feb 2019 12:40:40 +0800 Message-Id: <1551242443-27300-5-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:41:09, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-27 12:40:40, Serialize complete at 2019-02-27 12:40:40 X-MAIL: mse01.zte.com.cn x1R4em8h003706 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_get_next_child 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/pci-aardvark.c:826:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 798, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Thomas Petazzoni Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 750081c..56ecb16 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -794,6 +794,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; struct irq_chip *irq_chip; + int ret = 0; pcie_intc_node = of_get_next_child(node, NULL); if (!pcie_intc_node) { @@ -806,8 +807,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", dev_name(dev)); if (!irq_chip->name) { - of_node_put(pcie_intc_node); - return -ENOMEM; + ret = -ENOMEM; + goto out_put_node; } irq_chip->irq_mask = advk_pcie_irq_mask; @@ -819,11 +820,13 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) &advk_pcie_irq_domain_ops, pcie); if (!pcie->irq_domain) { dev_err(dev, "Failed to get a INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; + ret = -ENOMEM; + goto out_put_node; } - return 0; +out_put_node: + of_node_put(pcie_intc_node); + return ret; } static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) -- 2.9.5