Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1546863pxa; Sun, 23 Aug 2020 07:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiDU+BpJat5Zoq8Xc5OKe0QmbBr9emHPNXiRhh5TOSAmd327P93EgKQt0wtQSFF3k7y10C X-Received: by 2002:a17:906:5418:: with SMTP id q24mr1528875ejo.296.1598191585339; Sun, 23 Aug 2020 07:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598191585; cv=none; d=google.com; s=arc-20160816; b=KrPs/BiQALbAn7YlP7G5KB9cSbuC6P2SsE4N7Sz1uB5e8MRMj1KIWuaaLekoh6atbm OvziSrY2MD2DeJXRNJeWtpp6PYaBzoz/eMpNKNVQTZsiKJLJ2ZkcILwpVGj7iRUd1lSf BS1YS9VHi1+xXd22oSMWK0GlNj68oKZ7aV/XgXXqvN4olhS/PlzuGDrrEz3PbhYl4e0H ++jB37yDWZbupmgreGkWXSiYH6zybkAoevPqAr1U55pIDAaE0IqzdqkFy3FOyxyRq24i o+hE4PlUvH1DOI5SoPiw2Gclmr83fiHPmFM8FP6N9NaEgAL2WdHNIKyk8Kp3auc8UjI+ xTJQ== 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 :dkim-signature; bh=TlsZGie0Pmq1ULANAaf92cPvcSYg7hONtV2IZVBlGx0=; b=jrYubxneHYNcdSMDtRtREemSLeQq60kUzrZmh/8CJR89FThasRzR7pVyVwDHFwdIU3 Jj+sqZeJIopdc4goUKstO613tIySRzsNmrstC0YHLIPLaaXN6XNZTYJz5qgQg8p1fDUH NQQDRFOgMxJicW+GCvO1zVbGgFxPqkQI1v5vX1w326cbbs3WTGMbXnCPY/42JNtrLAOd 3GOd5tmIHEvkg8C8I0x3uieOxSCT/GsyXJQfQI2ohP52+pr6XJNfiPX0DnJA6Iq0g9T/ tdsU9PzPNXFSXexdeZbl/6HI7DsRTYvca+uDov/g2gbVGsUu6KUCuIl6L3gEn6+akeR3 SYJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FBm7IpmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si4270096edr.514.2020.08.23.07.06.01; Sun, 23 Aug 2020 07:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FBm7IpmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgHWOBo (ORCPT + 99 others); Sun, 23 Aug 2020 10:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbgHWOBo (ORCPT ); Sun, 23 Aug 2020 10:01:44 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D743BC061573; Sun, 23 Aug 2020 07:01:43 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id s14so2962950plp.4; Sun, 23 Aug 2020 07:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=TlsZGie0Pmq1ULANAaf92cPvcSYg7hONtV2IZVBlGx0=; b=FBm7IpmR8lFsFOm/8ZYSpn4lHcHTTlLQtfZ7gnrV+9KiCN7Z+4XW9HBRFhYCAlcrFo IegKHLWFZd1UkHFojFjnNltDYMlTWXU2lXJpBlQipRET6ZAxveZCthpajxQjss5Zf0Fd ynmVJHpxWPvnLkNLJhz0gqlBBDG39Sl6OB2u5yQfDJ4e/OQ+XN24CklX+9L9hl6VHcmD S4x8op5uNEZJd+mTCTWeZKCP9nr8b7ltoXA4wYNk2EgxM+kr1Ffa8mn7/rH1hcR+7rop K8jAzyqiq/obyOFReOMaKDFMA650dGvGDq6ePyVaPgO3tVecb0DM94WUru27QsRozWQH RJIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TlsZGie0Pmq1ULANAaf92cPvcSYg7hONtV2IZVBlGx0=; b=Jzh/T2rARQD98IJ2JskBW0i0ODBFVoyUxHTQc9EelOCXFk8edcHGR13HspWaq89uXa wAeI2ejq3jm4eE8WxXb5WcdCiIxxv1RjNX7tIUyyzrmnFfdbttPAH+UtTT2g8tiPGpCf jdMninKWxpP5hgsS3AXsfvc8v7PjBwJBJ0kD/s9EJOlMltFHYRYjivwf+GqfIAYffl96 26X+0mOWzLBX53FvFF8YQuXJb441WW0CEkI2XcwB6tbcM89JtZzCRmX9TkR6wz6baVri PrMWecp0vRg99phePKqzlKDBYqJehRUn7ZEmXv/Ug4lq3+kDj3gNYevdBuDHHsjUalr6 UooA== X-Gm-Message-State: AOAM532bdgdfdwLlXxBLPg7yV+n3NhnCJps5xvdcOHRLASJbYnauR2m2 JM7rXNsXtujbyZkHYHQ48Tc= X-Received: by 2002:a17:902:10f:: with SMTP id 15mr976200plb.121.1598191303470; Sun, 23 Aug 2020 07:01:43 -0700 (PDT) Received: from localhost.localdomain ([49.207.210.11]) by smtp.gmail.com with ESMTPSA id t19sm8291639pfc.5.2020.08.23.07.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 07:01:42 -0700 (PDT) From: Sumera Priyadarsini To: davem@davemloft.net Cc: Julia.Lawall@lip6.fr, andrew@lunn.ch, sean.wang@mediatek.com, vivien.didelot@gmail.com, f.fainelli@gmail.com, kuba@kernel.org, matthias.bgg@gmail.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Sumera Priyadarsini Subject: [PATCH] net: dsa: Add of_node_put() before break statement Date: Sun, 23 Aug 2020 19:31:16 +0530 Message-Id: <20200823140116.6606-1-sylphrenadin@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Every iteration of for_each_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in mt7530.c by inserting of_node_put() before the break statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini --- drivers/net/dsa/mt7530.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 8dcb8a49ab67..af83e5034842 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1334,6 +1334,7 @@ mt7530_setup(struct dsa_switch *ds) if (id == 4) priv->p5_intf_sel = P5_INTF_SEL_PHY_P4; } + of_node_put(mac_np); of_node_put(phy_node); break; } -- 2.17.1