From patchwork Tue Sep 1 15:10:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 310261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79A0DC433E2 for ; Tue, 1 Sep 2020 16:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D2972087D for ; Tue, 1 Sep 2020 16:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598979317; bh=7PC9BQif68XqqFEG9ytLgGPrX/aktloSK91Ow6LgB4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cQPjCcSeYVSvDfySIBxXzcire+OV1bCd3pTYSEn3Jp7WyvIPLJhDgkW86my4+gSFh mijmXYqQy5SqqZHArUr6f5rU5rqa1VQVMkcGlfuFJWrHzOAljJ1cOoVhErfcf8iS5U ouzHSImYHdUiGgYW5zsS4wVMJeiGhGRBwiJ428kQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731886AbgIAQyi (ORCPT ); Tue, 1 Sep 2020 12:54:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:48332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729698AbgIAPYY (ORCPT ); Tue, 1 Sep 2020 11:24:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC1272151B; Tue, 1 Sep 2020 15:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973864; bh=7PC9BQif68XqqFEG9ytLgGPrX/aktloSK91Ow6LgB4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6Wn4Jv7nnPA6Gy82aLZi7F9pli7qcYkT+rTegEtZDMLzLukEFdtKZzGvtX5uVkpG L6DaAWu5qMekCfK6FiuXLgq3+pecj1Y2obwS1sMa0b/xzvV5A1SKY/AVuNDeczuZJs lTCXPk4oSUDymXuPva1WeR7zqP3iI69RSmxANWN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumera Priyadarsini , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 078/125] net: gianfar: Add of_node_put() before goto statement Date: Tue, 1 Sep 2020 17:10:33 +0200 Message-Id: <20200901150938.395932806@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sumera Priyadarsini [ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ] Every iteration of for_each_available_child_of_node() decrements 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 gianfar.c by inserting of_node_put() before the goto statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/gianfar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index cf2d1e846a692..8243501c37574 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) continue; err = gfar_parse_group(child, priv, model); - if (err) + if (err) { + of_node_put(child); goto err_grp_init; + } } } else { /* SQ_SG_MODE */ err = gfar_parse_group(np, priv, model);