From patchwork Tue Aug 27 07:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2702C52D6F for ; Tue, 27 Aug 2024 07:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WqA/rD+DX2YKCxo+jGet4FEZG/AkfrfCDFP9EWV1cE0=; b=T7hKVeOsx6ctM8rYo/MYkWPf/1 Jet6V4YDcjqCsEPiBMS1w3oNFBuvpMo+6aH8DLYZMYoj7/S37VIhQNh8dnjSQGY4phIvwcpf5rQAu S6bVmDE1YXuKWRkffSXdHApIL9HCLeH6RC092Km/szXv0Uwd47WLj7ECQRfgf3jqmPVMEVC+wC90U 4x5begKKYP1d+sA2cRmtZ+xCTsWUa70ZE5LhhWDFY5koUjjNxCXbIEd8tTmMFwE8ghjvNLYnByLsi X9L7rpxuc/b54wL7OepaRahLtUDt/CYnO5LL4CVqebRqm2EMAs/TRTyzOIcJX1+c8HUM+u/C23mBE B6a+17gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siqtp-0000000AH4B-05It; Tue, 27 Aug 2024 07:45:57 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siqsW-0000000AGgp-016N for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 07:44:38 +0000 Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WtKKs5ltyz16PVw; Tue, 27 Aug 2024 15:43:45 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 7713E1401F1; Tue, 27 Aug 2024 15:44:32 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 15:44:31 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH -next 3/7] net: phy: Fix missing of_node_put() for leds Date: Tue, 27 Aug 2024 15:52:15 +0800 Message-ID: <20240827075219.3793198-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827075219.3793198-1-ruanjinjie@huawei.com> References: <20240827075219.3793198-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_004436_317983_F07EBB26 X-CRM114-Status: GOOD ( 11.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The call of of_get_child_by_name() will cause refcount incremented for leds, if it succeeds, it should call of_node_put() to decrease it. Fix it by using __free(). Also use for_each_available_child_of_node_scoped() to simplfy it. Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs") Signed-off-by: Jinjie Ruan --- drivers/net/phy/phy_device.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8f5314c1fecc..2fca33ff79e7 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3407,7 +3407,6 @@ static int of_phy_led(struct phy_device *phydev, static int of_phy_leds(struct phy_device *phydev) { struct device_node *node = phydev->mdio.dev.of_node; - struct device_node *leds, *led; int err; if (!IS_ENABLED(CONFIG_OF_MDIO)) @@ -3416,14 +3415,13 @@ static int of_phy_leds(struct phy_device *phydev) if (!node) return 0; - leds = of_get_child_by_name(node, "leds"); + struct device_node *leds __free(device_node) = of_get_child_by_name(node, "leds"); if (!leds) return 0; - for_each_available_child_of_node(leds, led) { + for_each_available_child_of_node_scoped(leds, led) { err = of_phy_led(phydev, led); if (err) { - of_node_put(led); phy_leds_unregister(phydev); return err; }