Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp631670iog; Mon, 13 Jun 2022 09:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysqZqv3b19lDD1iqVtPTkXtsL+FWp+Ck/8fYM3ipXt5PNaG4EX5xOzLp3qmTDgXIDQuiqs X-Received: by 2002:a17:90a:680d:b0:1e2:ff55:da6 with SMTP id p13-20020a17090a680d00b001e2ff550da6mr16667427pjj.133.1655137859553; Mon, 13 Jun 2022 09:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137859; cv=none; d=google.com; s=arc-20160816; b=PT5AKrxOVHSpc4N8nJG4syB+kWTdkigGyzQd06XmOBVWyq+zMgIc0oNfSLJvI9yLfD xdz+pBD5yfpW7Hi+IQTpjUr1bQ6mgDXK8IpG+MxM8Nuh2+Jrb5nQUlS3oStaFTv13Xq+ 19VJEGEjumCvyFk/XouI/bnvkPKTMvdtysNNI3GUYJFmyocRq2h1xPNoHeQwKUdHIRXU AkXjpbEeTvG9yW7Aoq3iwNkdAjacqMTr2n1RRjTF7jzY0tnu/kfIqRVFlveWcwtbuiT5 NaUNaBsvQzyYS7TI83aCTzoU8G2jzzKklspJqISZhaCgLQz+R9ZkV51OKuP22MrJRF8d xhRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5asfzwX/6aFmUClFgJoDOpZlIVBf74/I9U7uE5gjMsQ=; b=jQHrSHM1PiNTL/t9P/P7fyli4uPy58Sk3c4jcLAnzfADZ6lbBm+rrwj/yb3WmPSCoq 71JAKFgjzelv+GqLOWaAeIDBd+PFMQGURsj89r/ThwQJHJeJFPLbc1mJrAo84gJODYCZ Ka1WyKW3wojSDtqJGJHBWL9Pb13lU6kZ2WwxPyg7owL2AIosuKGCts5EOU/pWWrdhsS1 ZIGb7eTyhWFfI27fiUoZbhi1uITSmRoy9ZY9PuJBA/WC2vgEBU/knrkadKVPW56M1D6/ oPy7NolgpLMHTgOJHQHpWt1ZyueMvfR0WGUrhlKhEigg4SwdaJgfw6kXTWZsN8yYOLui m0gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HZVVmlVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a63e504000000b003fe26a09fe1si10064215pgh.477.2022.06.13.09.30.46; Mon, 13 Jun 2022 09:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HZVVmlVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381645AbiFMN5E (ORCPT + 99 others); Mon, 13 Jun 2022 09:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379611AbiFMNun (ORCPT ); Mon, 13 Jun 2022 09:50:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A8292A710; Mon, 13 Jun 2022 04:33:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AD948B80EAB; Mon, 13 Jun 2022 11:33:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CCEC3411E; Mon, 13 Jun 2022 11:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655120003; bh=hXyxhyEqCvPJVvbXeFOnshaIzEDrX6tP9ys6NmuwyV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HZVVmlVYqSd2AEP+sFWu24qf54gSablPc4oOCJLmaNSyezqEucjWAVn8R0kbDbKPw HXuqmnO7PLKmN/NpipaoRlpZiAhi5XDXbxcdVGid/JFCnWcV/ObGamLyyCXdREvWc9 RKeEH6bSZSJIwUt+rlQuTs1/Cm3FkQxUqmHid6jA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 215/339] net: altera: Fix refcount leak in altera_tse_mdio_create Date: Mon, 13 Jun 2022 12:10:40 +0200 Message-Id: <20220613094933.183831905@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit 11ec18b1d8d92b9df307d31950dcba0b3dd7283c ] Every iteration of for_each_child_of_node() decrements the reference count of the previous node. When break from a for_each_child_of_node() loop, we need to explicitly call of_node_put() on the child node when not need anymore. Add missing of_node_put() to avoid refcount leak. Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220607041144.7553-1-linmq006@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/altera/altera_tse_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index a3816264c35c..8c5828582c21 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -163,7 +163,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio = mdiobus_alloc(); if (mdio == NULL) { netdev_err(dev, "Error allocating MDIO bus\n"); - return -ENOMEM; + ret = -ENOMEM; + goto put_node; } mdio->name = ALTERA_TSE_RESOURCE_NAME; @@ -180,6 +181,7 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio->id); goto out_free_mdio; } + of_node_put(mdio_node); if (netif_msg_drv(priv)) netdev_info(dev, "MDIO bus %s: created\n", mdio->id); @@ -189,6 +191,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) out_free_mdio: mdiobus_free(mdio); mdio = NULL; +put_node: + of_node_put(mdio_node); return ret; } -- 2.35.1