From patchwork Thu Mar 31 21:42:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 8784781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4129EC0553 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 5CBDE202E9 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 1C9A8201C7 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 1aoZHh-0003y5-ML; Fri, 08 Apr 2016 16:29:25 +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-0003vy-Cd 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 e128so78736285pfe.3 for ; Fri, 08 Apr 2016 09:29:01 -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=W/gFwr7eHulmrBIi0yiR7/s1yeQfoz17e2XL1V6R+TvtWso0kF1BXNO4mA1JDQUooZ 23Ir3344t/sy5P4vQA0FEVe1AgAWfoeJ8CmN74Gtvh4skihNdaJWahPGhJlB0vKSrGZe vc/ANQR+uEcVvlBhx49+5FFOwWK5ZZkJYAyPh1qvEToemOBnYb7HAgumopkZhHZEfERe /U+ItbKhBahOOQ/JKbW/BjfntDJr2RfWWcAgM6Yxb1KGaCjjNUZ+nOSFcvVxzxU+w8bI ryF9xEPi4DjViUMW25MmhFmVEDVVBoZi7m3k80fcSBykvCviSXNNPWEKDZCibh5uCKcp MKiA== 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=lNIwn9o4PEsfwj3VkPMJWt0yucNdqTezGzDHHofGPX9suGK1Dsv7C1aPJSe5RhUND5 jTj86rGkUDovdtVWygVTs8kckv2WXAFCgbinRL0U4CrvE3a83NkHRyY4YbzOUqnatMk0 DwGC4bVd3RVU5z5UNyxGB/xHwoTHpb9iY+I83RDgxxzxlyF1MnFOhZj8hOVUcLmTFjxK K46yf1oPsSop0G+3VXwm0SoQLrR4Ho3mgxTJ5vdYRa83O4ubgUWe+mTTb6YfeLD7tXFO DwYdnhEmqr0rl18Mgk+NrF1pkRtlqLhuONGRauWU//Cunaq/aTG3/pil340hoRlVxIMo BFXg== X-Gm-Message-State: AD7BkJJD5CmygZNkcPHNlBY3s+TriwUjjRo7ZiHjzCzro/OXXFuaweddmOosFOxBsfUVUA== X-Received: by 10.98.32.23 with SMTP id g23mr13885912pfg.74.1460132940828; Fri, 08 Apr 2016 09:29:00 -0700 (PDT) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id g23sm19804767pfg.35.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 u38GSu2H004631; Fri, 8 Apr 2016 09:28:57 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u2VLgoEa002490; Thu, 31 Mar 2016 14:42:50 -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 14:42:48 -0700 Message-Id: <1459460568-2458-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_484145_0EF5AC46 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: