Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp446411iog; Mon, 13 Jun 2022 06:08:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIX9aOQbilfXszVYs5hqN50mQjW8oiFnAJ4GXoKsbAdJhJodsDqrOMWEsP5FUFvbsigWnJ X-Received: by 2002:a17:903:258b:b0:163:cf73:c083 with SMTP id jb11-20020a170903258b00b00163cf73c083mr59331468plb.127.1655125657247; Mon, 13 Jun 2022 06:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125657; cv=none; d=google.com; s=arc-20160816; b=E/OjfI5DQ9ZUgADXJPwVX+VCBXemeeUeNucxVewEhmB+zF1Pa5z/EKBv2dVsuHrXp8 YtRDn5JO+tQpkJaAyH1qR6jW6fwYhSiamsvya4LbohhDhp5sdcLmIi34HuTc0fQSZ7eZ I78TK68ooSP9f+rqK+SESTxYW+UGkTsG97kBO6xcxq0If/smSg6wOsubasVKOAX2VFQE 8Ti38f+JwPijkdhTUPmYl4GpIcxQ5jnULShJVCrZLW/QATwC/jLVLIGzToFYHAkQDh8U yoqh4sRtJLsttJKf8+FG4RfYQuRO+P/dhEYOFJLH9MetBj5vBvt5V8L30iAKofIXF+tU S/Pg== 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=wK8GWd02aMFVlnjB/3NNBF5wXLnXW9iyO2vQF1GnA/g=; b=T57DiePtgMY08qcK5rXslxZkrUjJCaoNhkPFukqf+RqbdaLGJmUe5YX1x/7xkhzi7y susn9MpmDtHkZa4MvsEvkl5FoIFe0V0RrkmwW9PsQlJoaqdi/0+fphiGI2xTz+xfUIYv TloUiF4yrg2n97ZH4sh0myuVqfZuMYTPvTRxuI6zlq8xv6o6DFjsDY3L+x0r4QjMT4RU iXDp+KGruyIA5OBEkLEW2AdSdJIzgiTaPgDE+V0yqPlq2f6aE5tkzj3aXdKK+AVn9X3K Ni87HAQrKUtZWTI2HeHEsn1aKWXluX09XIpMwiPlaIrsZLXyJYEywvBIZ/GNoJcBR7Q4 ENJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bqvfc65A; 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 q13-20020a170902dacd00b001622a77631esi10686815plx.594.2022.06.13.06.07.20; Mon, 13 Jun 2022 06:07:37 -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=bqvfc65A; 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 S1352003AbiFMLJN (ORCPT + 99 others); Mon, 13 Jun 2022 07:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351683AbiFMLEw (ORCPT ); Mon, 13 Jun 2022 07:04:52 -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 32419326F8; Mon, 13 Jun 2022 03:33:50 -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 A8DC561021; Mon, 13 Jun 2022 10:33:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C6F9C34114; Mon, 13 Jun 2022 10:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116429; bh=04mpPbox/M0M1E7bmFFkKF6WQganXPbe2XFAbJrCpzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqvfc65AWUKzGxsmJP32SVhsdiKjAuUtfrKy7nb3/kkhWx+GNP9h4NhmPIHkcLN/f +40JCH65cZdb8YstdpcqAEqE+YwNX6Oap20uP5Cg2UIeZvEkdO0FroIM8fvtEAPc8V fHIn8M5s0g+3ysiG+ezfc8SSrq9jX2UiieEm43Os= 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 4.14 179/218] net: altera: Fix refcount leak in altera_tse_mdio_create Date: Mon, 13 Jun 2022 12:10:37 +0200 Message-Id: <20220613094926.036539840@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@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 691fd194e5ea..1c0f11ec7a83 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -174,7 +174,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; @@ -191,6 +192,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); @@ -200,6 +202,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