Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1258834imp; Thu, 21 Feb 2019 23:18:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IafXNTqRHuBKl1MMEo+9uolLcZO/S/5N8hzw6XDclX12Aynf43jHohV4j2WJUt3PmcalJMk X-Received: by 2002:a65:4784:: with SMTP id e4mr2626512pgs.12.1550819937134; Thu, 21 Feb 2019 23:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550819937; cv=none; d=google.com; s=arc-20160816; b=K9856ub5JiyqmJBW9kaEvER1iNYio+8LHBU51EtT5p9aWcvVCO9PnaMHu0rKP4+G1M HmJogKhYjvdaR+FijR1gh7+ezBRzTJVkdWvNY/D1gTWpYOqOZzRlHOIJR2LtxazjlmFI tOgh1ihaT2eRuuxeuhH5jZgmApue9nTDOLPh5CsS7j6RY7h6BEPkW3GbHTw6vXvqCHLV Rq+zCQXUbhycCi3WgA1aXcSjWk4bG6y/6oyCVmb95jkrxhEBCJKPaY8CLY+sGc9pbKdC clgfEWrkF4Fotin5yYnBGZNuxATjZC7kHWgUKiDWF0h+n07mdN5EgUundgHfOrB59hOD FBAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=l1GyhMlTlXnWX9p9tToUjLHMe8Twh4fMN60KtmO28uc=; b=KEYWjDvKIBczyk4yusrNSBf26Sy20eRiJShUOBbGp6e+0iA7Ji4ki0an+2PAspla4B VvT9fKzVrd+xPkpqohlAj2TakBf0528LijMjrW5FHxxDWsxP4bYGeA//ic/2dOcVIq/v EEzAbNBr8vAlXCqcMORVrv3R1i2hAZK24aKGhCuHvUt6nWlq98WXTpwpWQs+KwsbPX5V VV7q/84uGJjfCEXcFIGEYjGO7nACusplKX4c0EjvKDI0+mqenFIwuajlOuufuQIORD9G jbF6Vbic6aRRpofT76PzcYK+z1mzbOd9PKqzxMGpiKwtZsTal9JDH3jIB5NkPFw1rdYi f78g== 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 i7si689894pgs.147.2019.02.21.23.18.42; Thu, 21 Feb 2019 23:18:57 -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 S1726320AbfBVHPp (ORCPT + 99 others); Fri, 22 Feb 2019 02:15:45 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:25256 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbfBVHPo (ORCPT ); Fri, 22 Feb 2019 02:15:44 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 2CF9DDD809A2863B0878; Fri, 22 Feb 2019 15:15:41 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1M7FLSP037220; Fri, 22 Feb 2019 15:15:21 +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 2019022215155958-1228853 ; Fri, 22 Feb 2019 15:15:59 +0800 From: Wen Yang To: linus.walleij@linaro.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, nbd@nbd.name, lorenzo.bianconi83@gmail.com, kvalo@codeaurora.org, matthias.bgg@gmail.com, linux-wireless@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, anirudh@xilinx.com, John.Linn@xilinx.com, michal.simek@xilinx.com, wang.yi59@zte.com.cn, Wen Yang Subject: [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put Date: Fri, 22 Feb 2019 15:15:38 +0800 Message-Id: <1550819742-32155-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-02-22 15:15:59, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-22 15:15:05, Serialize complete at 2019-02-22 15:15:05 X-MAIL: mse01.zte.com.cn x1M7FLSP037220 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. Detected by coccinelle with the following warnings: ./drivers/net/dsa/rtl8366rb.c:510:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. ./drivers/net/dsa/rtl8366rb.c:518:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. ./drivers/net/dsa/rtl8366rb.c:540:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. ./drivers/net/dsa/rtl8366rb.c:548:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. ./drivers/net/dsa/rtl8366rb.c:556:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. ./drivers/net/dsa/rtl8366rb.c:561:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Linus Walleij Cc: Andrew Lunn Cc: Vivien Didelot Cc: Florian Fainelli Cc: "David S. Miller" Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/net/dsa/rtl8366rb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a4d5049..f4b14b6 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -507,7 +507,8 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi) irq = of_irq_get(intc, 0); if (irq <= 0) { dev_err(smi->dev, "failed to get parent IRQ\n"); - return irq ? irq : -EINVAL; + ret = irq ? irq : -EINVAL; + goto out_put_node; } /* This clears the IRQ status register */ @@ -515,7 +516,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi) &val); if (ret) { dev_err(smi->dev, "can't read interrupt status\n"); - return ret; + goto out_put_node; } /* Fetch IRQ edge information from the descriptor */ @@ -537,7 +538,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi) val); if (ret) { dev_err(smi->dev, "could not configure IRQ polarity\n"); - return ret; + goto out_put_node; } ret = devm_request_threaded_irq(smi->dev, irq, NULL, @@ -545,7 +546,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi) "RTL8366RB", smi); if (ret) { dev_err(smi->dev, "unable to request irq: %d\n", ret); - return ret; + goto out_put_node; } smi->irqdomain = irq_domain_add_linear(intc, RTL8366RB_NUM_INTERRUPT, @@ -553,12 +554,15 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi) smi); if (!smi->irqdomain) { dev_err(smi->dev, "failed to create IRQ domain\n"); - return -EINVAL; + ret = -EINVAL; + goto out_put_node; } for (i = 0; i < smi->num_ports; i++) irq_set_parent(irq_create_mapping(smi->irqdomain, i), irq); - return 0; +out_put_node: + of_node_put(intc); + return ret; } static int rtl8366rb_set_addr(struct realtek_smi *smi) -- 2.9.5