Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1540923pxa; Sun, 23 Aug 2020 06:54:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhNv4dxtW1wYTIItsVYVg5zEBfGjilozRXeRuN4pH8ko4muzw/cmycdO3StprBeRf5O8H1 X-Received: by 2002:a17:906:2e43:: with SMTP id r3mr1529996eji.232.1598190891932; Sun, 23 Aug 2020 06:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598190891; cv=none; d=google.com; s=arc-20160816; b=O+mx7mupon/0nbS9N9PEtYUTSvcRi97BlASqdTotYKZO1vgPEor2J8UGb6ByUe2Lw7 NECI8APoSgsnjISGLMZxvqnpRJDEky2CQIeMnglJ/yCP9F2kXO2O/EOesB48wM+VMoyW Yoxd7ZIfjFPkZM2/5qslcrtmpgtDinVuWuOCYqVLG/M0oSVC7wq8KBQGSom5FBOINEmt RChb+D+fhXbDiqR7tY41K+snlKqrFYzWpaqymOBR35VCe84x71Yr6jlHbrx6gMEHqW37 U2uN4uhu8FTcnQGT/v5Sekq2OZlup+HRG1FyrI54TDUC0wZQgPXAbMx3zreIyueP1RcA 9+Jw== 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=sD1FQMMwZynoPD77mgKlAipOywDFOvrgKbtU1x4LJuM=; b=viBoJXw508xFXyf78i58inYm7GA8q2Q6OGnrUgpRuJlEQ7qgGTp2uDXgXPsv8aMZ+9 JevzIm2T/RpMsUwxVHOTseAVu5Zm8CERk9d3PwJrmQPNIjqXNJkEc02Bwp++5FVpe4wm ZDcb9y2jIct5lbgLc9dulKTrXQrUvqAh66a2E5jomThQXi9dDWOAHSzyj58r21Lchtfm mxRibUqfYyTXZP+btOLOId93lR107TJCr+affIjzMF02s+A+itt+PBFHg1b+iiNMywmn /9cs5kc6OE8VW+Mw2uY7j4c2c4JK7Mxp/41VN3hWTz9uTOTUYSgpkXupbQAOtDRaIskg PBYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qehOR7pa; 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 b4si5257366edf.40.2020.08.23.06.54.27; Sun, 23 Aug 2020 06:54:51 -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=qehOR7pa; 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 S1726603AbgHWNxL (ORCPT + 99 others); Sun, 23 Aug 2020 09:53:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbgHWNxK (ORCPT ); Sun, 23 Aug 2020 09:53:10 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14E91C061573; Sun, 23 Aug 2020 06:53:09 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id u128so3432803pfb.6; Sun, 23 Aug 2020 06:53:09 -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=sD1FQMMwZynoPD77mgKlAipOywDFOvrgKbtU1x4LJuM=; b=qehOR7paicgWwy8oVrx6Nuwi91rx7RoN/PjXp7l/5c2jfA5zuQ2AffnvmTxmM1gO83 0jJ2YyJQJFphB61jAGK4SrjOiwN13ketztc9uabhakRxVR6DsmgZbWnWVQfDnUShZKdb s7ibsOiC7zb8UPMYiWZ1T/2oeZ3ULNs/5df6hDXPF2MxxknTEGAm6I7V0XdY6+d9R2Yv qM0JT81PCG7nTU5lO8TbINEzfE6/2NaWdI3I68xYTkMq7kl4No3Eyxh2sYrNxA5TftZ/ rzDP+IGLDikBccuT0C4Slrip4m8QpUCvJyHhJ+Nkf63QlbrnhGu6SiavRM/Uo0kQrrv5 1w2Q== 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=sD1FQMMwZynoPD77mgKlAipOywDFOvrgKbtU1x4LJuM=; b=OXTEuF068r2xvTd0obcg6Or0Ft67S4Yua1GezOnBbw4P+J9/BVVPDbKeghKlZWUSl8 +CoNsByaPz/7xt5GaI1r8fL4czi90/KkLQ+qBM+PU5FBtTLT2Muo3ZHyUKVIAmqwz7w9 Q/3fZIt3ShcEcBmO52G78su6iG8pYJpAqivCUzq7CJa6WBlCl+KIMoBbG6VELylbsH9w Vqs0fIvc82WrJR6qhapGps56ZJHuVvvDupEpg2zzhFPrwSKLkqebR/UDJkBtPk3H76gI mvdg5AQSmeFtC7GDmLnmuY899qJoOjjVaWq0dqV3/XW12DnGDF5tsWhuJZEipAjQirns xlzA== X-Gm-Message-State: AOAM533Bq5c13VqzNdqXPgpOCDKOg0TH6jKeTOmQJpdBdP0WiXdT0gsR WDm17Kth3NqFXop2RXkwKjE= X-Received: by 2002:a62:1803:: with SMTP id 3mr1079040pfy.198.1598190788902; Sun, 23 Aug 2020 06:53:08 -0700 (PDT) Received: from localhost.localdomain ([49.207.210.11]) by smtp.gmail.com with ESMTPSA id q5sm1290809pfu.16.2020.08.23.06.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 06:53:08 -0700 (PDT) From: Sumera Priyadarsini To: davem@davemloft.net Cc: Julia.Lawall@lip6.fr, UNGLinuxDriver@microchip.com, vladimir.oltean@nxp.com, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sumera Priyadarsini Subject: [PATCH] net: ocelot: Add of_node_put() before return statement Date: Sun, 23 Aug 2020 19:22:45 +0530 Message-Id: <20200823135245.5857-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_available_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 felix.c by inserting of_node_put() before the return statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini --- drivers/net/dsa/ocelot/felix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index c69d9592a2b7..04bfa6e465ff 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -400,6 +400,7 @@ static int felix_parse_ports_node(struct felix *felix, if (err < 0) { dev_err(dev, "Unsupported PHY mode %s on port %d\n", phy_modes(phy_mode), port); + of_node_put(child); return err; } -- 2.17.1