Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp625342iog; Mon, 13 Jun 2022 09:22:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sXtfoc2vuRXfZ5wcZyohk1NTqbwOrLwT7O6oIgoHqX13Hh5LqGvR15cEfKVV08aUIbVznM X-Received: by 2002:a17:902:b18d:b0:167:86f2:88c7 with SMTP id s13-20020a170902b18d00b0016786f288c7mr98479plr.103.1655137373582; Mon, 13 Jun 2022 09:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137373; cv=none; d=google.com; s=arc-20160816; b=Ti8kr0BuhaQPnM+8pe3cX/yRsPHZecfnW8MLClBGZuM/UuxAIFHXP/196xuLyoVdt3 zL+kk2kLoJSYVzW+bamN/PvUstxL0RHJkaVL+joAm3Xjz/iQFvoUylG8ff/Bqn6G6vws zTxCUhNQcgi1GQvPUuW63Tgdx0v70KsNUy5uIZyEBQdu5dFsdSGF34PFLC/RKirSZ9O4 G++OPhcqrfT+CFrg27MJdSr13cOGdvLEsOtQz2KvKnFxe0HeD7G8BBjFqU13e1/gZMdY P3elgrkA80JEAwQjJKwRAv2NrYfJj5a0XU/4d0VkznUTzo5j8QnvuaqhIrGFWaBR4L/T pLeA== 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=A5voAwimCdFQPbhpnHnzVCGwqD/S6fj0fvk9b3Zjzx8=; b=NuRbfILMpS1R3MqLWTrXK7QY8OHjClqIugty6QU1GydHPelp4hvwJbpExIS0r1p1kU QyAnfZ5iiPHummspbrgLu8fV4UlKjrKZXOOFJ47mYe5RQnCtJq5HpiP2FvLnCcHOdpA8 +QEPbJo22IXZh59orW15yqF3sR/spX514TKOTXwi3O/NBiM/KoNEHGEhO3a8paa2Hvs2 TWYZGiv8DhEoxjIIlC75e7GQ1MhwJhsZzNYj0BAgFstAKgTrBOzXbiuXRfIcQY1eJJC2 85E7aBPUqY4bQtKvIoALxex1n8KFwPXOEC1nIeyggn5TmQ5NeHw/bQ+CjEOLsAVORfyh FRbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=By6jrEdu; 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 bf25-20020a056a000d9900b004fa3a8e003fsi7764821pfb.246.2022.06.13.09.22.40; Mon, 13 Jun 2022 09:22:53 -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=By6jrEdu; 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 S1356418AbiFMLoc (ORCPT + 99 others); Mon, 13 Jun 2022 07:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355675AbiFMLjX (ORCPT ); Mon, 13 Jun 2022 07:39:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183202C678; Mon, 13 Jun 2022 03:49:44 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 76045612E7; Mon, 13 Jun 2022 10:49:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88269C3411C; Mon, 13 Jun 2022 10:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117382; bh=519MV+5N65k7kjuH3RLOH+9PVU1TJ2Gio8/uba4+zHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=By6jrEduFwkQrap7gVwlr1qCXMjL3DygkzgyBU5rZA8dZl/qioucWr1w5bs5yzOHd /i0mublOBl0ryObFvfkUtgvZAoyOZd4GUICyblVPy9mNr0jGR+AQ1HsjTdsCCW2Xef MmYTBto9yvMxcJRRXyV+8LB2qpa+IHsqzTBm2ow0= 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.4 363/411] net: altera: Fix refcount leak in altera_tse_mdio_create Date: Mon, 13 Jun 2022 12:10:36 +0200 Message-Id: <20220613094939.575669469@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 1f8c3b669dc1..f36536114790 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