🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #793

[PATCH] net: mvmdio: fix clk reference leak in orion_mdio_probe()

#793
From: Haotian Zhang
Date: Thu, 08 Oct 2026 16:53
48 lines
7338 bytes
orion_mdio_probe() calls of_clk_get() with index ARRAY_SIZE(dev->clk)
purely to test whether the device tree declares more clocks than the
driver supports.  of_clk_get() takes a reference on the returned clk,
but the return value is only checked with IS_ERR() and never released,
so both the clk reference and the clk allocated by alloc_clk() are leaked
whenever the DT node has more than four clocks.

Store the returned clk in a local variable and release it with clk_put()
after emitting the warning.

Fixes: ea664b1bdc19 ("net: mvmdio: print warning when orion-mdio has too many clocks")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/marvell/mvmdio.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 2ccb8c8f5feb..17537142be6d 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -286,6 +286,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	struct resource *r;
 	struct mii_bus *bus;
 	struct orion_mdio_dev *dev;
+	struct clk *clk;
 	int i, ret;
 
 	type = (uintptr_t)device_get_match_data(&pdev->dev);
@@ -338,11 +339,13 @@ static int orion_mdio_probe(struct platform_device *pdev)
 			clk_prepare_enable(dev->clk[i]);
 		}
 
-		if (!IS_ERR(of_clk_get(pdev->dev.of_node,
-				       ARRAY_SIZE(dev->clk))))
+		clk = of_clk_get(pdev->dev.of_node, ARRAY_SIZE(dev->clk));
+		if (!IS_ERR(clk)) {
 			dev_warn(&pdev->dev,
 				 "unsupported number of clocks, limiting to the first "
 				 __stringify(ARRAY_SIZE(dev->clk)) "\n");
+			clk_put(clk);
+		}
 
 		if (type == BUS_TYPE_XSMI)
 			orion_mdio_xsmi_set_mdc_freq(bus);
-- 
2.25.1
Technical Details
Message-ID: <20261008165328.2702289-1-vulab@iscas.ac.cn>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343132-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343132-linux-kernel-netdev=dewy.ru
From: vulab@iscas.ac.cn (Haotian Zhang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] net: mvmdio: fix clk reference leak in orion_mdio_probe()
Date: Fri,  9 Oct 2026 00:53:28 +0800
Organization: Usenet Network
Message-ID: <20261008165328.2702289-1-vulab@iscas.ac.cn>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="923348"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:EU2ZQ+k1YuwK1qxItcSFiYlXtSk= sha256:GmcydAbiP6NZhlQ+2oIbr6vS1HCk7tSaJB40LJXqSxY=
	sha1:mwpi1/rIuOpLkp6iHoDf2ug+rCM= sha256:wWBHOtC8p8Syzn3RCfIltfNWzGf8aPplo/ZqG7DZhi8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4573F10F481; Thu,  8 Oct 2026 19:57:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.651
X-Spam-Status: No, score=-0.651 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id zgySVQn9Qt7I;
	Thu,  8 Oct 2026 19:57:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-343132-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 35DCA10F470; Thu,  8 Oct 2026 19:57:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 6F63A29AA3; Thu,  8 Oct 2026 16:53:38 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id F2FD93A83AC;
	Thu,  8 Oct 2026 16:53:37 +0000 (UTC)
X-Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81])
	(using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7E583ABD80;
	Thu,  8 Oct 2026 16:53:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791478417; cv=none; b=psnyCs2cvHxRlXZDLinjFfCEVRUqRMkK2JwY/oOEaR9+KwAM5AQ7hikR6UtfW4b7rwiOecUBSepM0cJsgLhzpRxW3kG4TurblraIlsh+kkv62DS/2QwVGe9qu2qe0gTu2ttBKzJTpid0LB+y9sUSYggHJKRS//aooHWj7O7AmxI=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791478417; c=relaxed/simple;
	bh=CHrg/5nhW8ZoRHnxM/UpD41foj63PkOKAilIxgokRvQ=;
	h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B5Ug2756HkiD1POTe3d71GUx0+a0IfU47gFWMi1RhJser6i24zRitfNbbTS7lLA1J95SqYFNx19wh4LWTCK+PHn23ANkUwyO0PLNU1Q/PHbUmk1uNT6UnscjMZmGAB22oqeHOCCNhbUJpqOTZcedQZHq44aBuakNhQ4sx/bm7yI=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn
X-Received: from fc87d0ffb700.home.arpa (unknown [36.110.52.2])
	by APP-03 (Coremail) with SMTP id rQCowAAHED6FysdqbYoOCg--.13658S2;
	Fri, 09 Oct 2026 00:53:25 +0800 (CST)
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.25.1
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-CM-TRANSID: rQCowAAHED6FysdqbYoOCg--.13658S2
X-Coremail-Antispam: 1UD129KBjvJXoW7tFyfJr1rKr1fZFy8try7Jrb_yoW8Cr17pa
	yvgFyYy3yxJFyUW3WkXa18ZFyF9a1fta4fGryayanY9343GryxZr93GrW0vrWUJFWkCw4a
	qr1UAa1xZ3WDZr7anT9S1TB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