Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4420767imw; Tue, 19 Jul 2022 06:23:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vJaTKbtN4pU5am5FT0Xayyg6sDwrqLTg81tUcGQxhVyZkkOhzLT3ywfc5GjJo0QnmQtkSt X-Received: by 2002:a17:906:cc0e:b0:72b:311b:8ed9 with SMTP id ml14-20020a170906cc0e00b0072b311b8ed9mr30710943ejb.186.1658236991744; Tue, 19 Jul 2022 06:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658236991; cv=none; d=google.com; s=arc-20160816; b=IugDByyLav1ry4D6ekdDaAR/7BY2ZKwOkRTftn2jAwTjZiAUThTGInQsZVhY6fQUXl XgsDIc1Uf4uW1qMPK0L9wiUunOcR5z8GUBa7VCEaZmuhu0GDvqb5XtlpdQ501ZlW421j q/LRzrVxMrfLVdCODsdRz2h6CyberTW+FaAB/xF/G0Q0rDaLtywkSr47MPITXD7AFTLx zicy8MBQrZ0ryd0P4tkPcKhT6yeKp2pZ6m7GeiMVvKNdyX6SBiZsDlWPm+08MFLY3d03 Qq6ezpfuwcU6Wye5z36FfHvuMkBHQXw+9PAkvFgpx0cTQbXT/xiEAQgVhSLYqpNTctlK rqTQ== 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=gqhbtV8Ewz01FYKlFHjSrlRKsmzDFO/oF8UvL5mtnHY=; b=tY1j/DOnuopAnaEFLBUlYszMA2hneB32Wad0i5LzMiBGpgQsasJxbMbHxN/XyNIW+7 4phF6I/STNIligNmmxTFi7xu/y3bXvbe541vf+nCjtew6hN77ydNrQgl43oTtrlX//Wz 2GOgY/CDvYY3kFEmisNuVLWIngqNpIPGJU/ZVn5Ev53t1SRLBMxKCgLJjJMx7AyWoqH6 iw4RYhYkAUkoMLBrw+ctq4YNHBX9U78c57OGZJA98c20CyZFdfwkIVksqpENKRhh15qk BDO1BeEQ7f95N0WDNIF/BFekeAWDqzzdNd2zA0AzPiMvVszcLfyRnmy5mVzT2beXckUB jo9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=STeiOMS+; 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 t17-20020aa7d711000000b0043adae91e5csi16947692edq.611.2022.07.19.06.22.47; Tue, 19 Jul 2022 06:23:11 -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=STeiOMS+; 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 S239776AbiGSMZi (ORCPT + 99 others); Tue, 19 Jul 2022 08:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239925AbiGSMYY (ORCPT ); Tue, 19 Jul 2022 08:24:24 -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 102DC61B1E; Tue, 19 Jul 2022 05:09:15 -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 DFC1E61632; Tue, 19 Jul 2022 12:09:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 899D7C341CE; Tue, 19 Jul 2022 12:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232554; bh=YwRFyBy7QOPPp2kPstqZecqGS1HzSXF8dbmCJJwpdOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=STeiOMS+RPaERL1E4+PltavjnYnXcrXvKOmgQxY7+5kXH8DdW0IE5cErrVcYC2LAm iviM3PAluYSOeafnYXnV+bLPvBuzYNHjHKb2oH87t0Yyim6+pKbrDzW8a/AgnPZLr4 yhFKS00ypkqGR1Qqdu0FgzsU8mYsfv+7d0mw/AmQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 064/112] net: ftgmac100: Hold reference returned by of_get_child_by_name() Date: Tue, 19 Jul 2022 13:53:57 +0200 Message-Id: <20220719114632.679850919@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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=-7.8 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 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: Liang He [ Upstream commit 49b9f431ff0d845a36be0b3ede35ec324f2e5fee ] In ftgmac100_probe(), we should hold the refernece returned by of_get_child_by_name() and use it to call of_node_put() for reference balance. Fixes: 39bfab8844a0 ("net: ftgmac100: Add support for DT phy-handle property") Signed-off-by: Liang He Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/faraday/ftgmac100.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index eea4bd3116e8..969af4dd6405 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1747,6 +1747,19 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv) return rc; } +static bool ftgmac100_has_child_node(struct device_node *np, const char *name) +{ + struct device_node *child_np = of_get_child_by_name(np, name); + bool ret = false; + + if (child_np) { + ret = true; + of_node_put(child_np); + } + + return ret; +} + static int ftgmac100_probe(struct platform_device *pdev) { struct resource *res; @@ -1860,7 +1873,7 @@ static int ftgmac100_probe(struct platform_device *pdev) /* Display what we found */ phy_attached_info(phy); - } else if (np && !of_get_child_by_name(np, "mdio")) { + } else if (np && !ftgmac100_has_child_node(np, "mdio")) { /* Support legacy ASPEED devicetree descriptions that decribe a * MAC with an embedded MDIO controller but have no "mdio" * child node. Automatically scan the MDIO bus for available -- 2.35.1