From patchwork Fri Apr 1 01:01:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 8784791 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 750179F36E for ; Fri, 8 Apr 2016 16:31:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93932202EB for ; Fri, 8 Apr 2016 16:31:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BFF06202DD for ; Fri, 8 Apr 2016 16:31:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aoZHn-0003yZ-Jk; Fri, 08 Apr 2016 16:29:31 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aoZHe-0003w4-CU for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2016 16:29:22 +0000 Received: by mail-pf0-x234.google.com with SMTP id e128so78736507pfe.3 for ; Fri, 08 Apr 2016 09:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ek6tOoHGnCrFf3wrL2Lj/+bFHWhJTorvo52I/Dl/tNc=; b=QYMmk0nX82ZN2mO3rDUYBrXcCsPWAZ7B5VbD5ydqORIpy/p03LT5AfWlAOuHcwmQZh xVnPMylrYLlVR3Hi2cyRQBcDeAYrVqc+SJ0F+OmuaaGG5dJ08jG/L3RaEKCZ/b2K4ecj 18UUMK5eysgG47Sd2HtdmEJH5ZxVF9O0FPyDkwqspf8tSVAHSw6Q4SXUDyIe5Ch9jtHf LNMVVShBYQxhY7ASyyVskhS7cYrnMTbBckQsB1l5heSgDcQBcqaygq6YMAVFKmX0ZvhW FyiHBG3tswUvOMJMBmoRIQENCXBB3wfGqQRTka6GCqHEc9zBIENbNHPDMTjKlgCmTUYu e2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ek6tOoHGnCrFf3wrL2Lj/+bFHWhJTorvo52I/Dl/tNc=; b=X9QlZ3HVbDBxTOwNnzWB9ms1hz3VKOUezt3SxB4M2gj76Fuurxb/hLtURJFP9euPPE +BqPxBg8mdXQ2wFksBD4NIyW1+d3mQTwWlBbgzEc0Zd56pYcAirvCXRU6XOeTLTsA+Nk 1Dx6nUO5VjYB3wmVcm5Kk7e6adBBe2+C4jKihAe+WbkGxazFR0bz08j+eqTmRsVVFvym rDmCsC3vemEOeRV47msEdql7b+448Is4eI4wDsTR6jp03Dsa2/IQY+qyncrtRUqAJF2J L0QzIMa4Jcjb//oSB7mdvWtkm31X8wUfbuYCvRPzZwe3V0kRg36Rra11OubrJ1S/143F GpdA== X-Gm-Message-State: AD7BkJI1nFvt1DuLwMwgfhC8SLsrqaQ5Cd8iusULkVofg6Z/ezAGkhME7F9w5Sz8baamMA== X-Received: by 10.98.8.196 with SMTP id 65mr13730087pfi.53.1460132941811; Fri, 08 Apr 2016 09:29:01 -0700 (PDT) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id xs10sm19851724pab.4.2016.04.08.09.28.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Apr 2016 09:28:59 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u38GSu2J004631; Fri, 8 Apr 2016 09:28:57 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u3111x6W005729; Thu, 31 Mar 2016 18:01:59 -0700 From: David Daney To: "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH] net: thunderx: Fix broken of_node_put() code. Date: Thu, 31 Mar 2016 18:01:57 -0700 Message-Id: <1459472517-5696-1-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160408_092922_474390_E7C0D2C6 X-CRM114-Status: GOOD ( 13.49 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Goutham , Robert Richter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Daney commit b7d3e3d3d21a ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.") incorrectly moved the call to of_node_put() outside of the loop. Under normal loop exit, the node has already had of_node_put() called, so the extra call results in: [ 8.228020] ERROR: Bad of_node_put() on /soc@0/pci@848000000000/mrml-bridge0@1,0/bgx0/xlaui00 [ 8.239433] CPU: 16 PID: 608 Comm: systemd-udevd Not tainted 4.6.0-rc1-numa+ #157 [ 8.247380] Hardware name: www.cavium.com EBB8800/EBB8800, BIOS 0.3 Mar 2 2016 [ 8.273541] Call trace: [ 8.273550] [] dump_backtrace+0x0/0x210 [ 8.273557] [] show_stack+0x24/0x2c [ 8.273560] [] dump_stack+0x8c/0xb4 [ 8.273566] [] of_node_release+0xa8/0xac [ 8.273570] [] kobject_cleanup+0x8c/0x194 [ 8.273573] [] kobject_put+0x44/0x6c [ 8.273576] [] of_node_put+0x24/0x30 [ 8.273587] [] bgx_probe+0x17c/0xcd8 [thunder_bgx] [ 8.273591] [] pci_device_probe+0xa0/0x114 [ 8.273596] [] driver_probe_device+0x178/0x418 [ 8.273599] [] __driver_attach+0x100/0x118 [ 8.273602] [] bus_for_each_dev+0x6c/0xac [ 8.273605] [] driver_attach+0x30/0x38 [ 8.273608] [] bus_add_driver+0x1f8/0x29c [ 8.273611] [] driver_register+0x70/0x110 [ 8.273617] [] __pci_register_driver+0x60/0x6c [ 8.273623] [] bgx_init_module+0x40/0x48 [thunder_bgx] [ 8.273626] [] do_one_initcall+0xcc/0x1c0 [ 8.273631] [] do_init_module+0x68/0x1c8 [ 8.273635] [] load_module+0xf44/0x11f4 [ 8.273638] [] SyS_finit_module+0xb8/0xe0 [ 8.273641] [] el0_svc_naked+0x24/0x28 Go back to the previous (correct) code that only did the extra of_node_put() call on early exit from the loop. Signed-off-by: David Daney --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 9679515..d20539a 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -1011,10 +1011,11 @@ static int bgx_init_of_phy(struct bgx *bgx) } lmac++; - if (lmac == MAX_LMAC_PER_BGX) + if (lmac == MAX_LMAC_PER_BGX) { + of_node_put(node); break; + } } - of_node_put(node); return 0; defer: