🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23282

Re: [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link

#23282
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 01:43
130 lines
12359 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] hix5hd2_dev_remove() in
  drivers/net/ethernet/hisilicon/hix5hd2_gmac.c still calls…
- [Medium] The commit message says phy-handle takes precedence over
  of_phy_is_fixed_link() (for managed = "in-band-status").

--

net: hix5hd2_gmac: Support fixed-link

This patch adds fixed-link support to hix5hd2_gmac. When the node has no
phy-handle, the driver now registers a fixed PHY from the MAC node. It
also skips MDIO bus registration for a fixed link unless an "mdio" child
node is present.

> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index b3b2aa1b76988..eeb7221c0cde8 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c

[ ... ]

> +	bus = NULL;
>  	mdio_np = of_get_available_child_by_name(node, "mdio");
> -	ret = of_mdiobus_register(bus, mdio_np ?: node);
> +	if (mdio_np || (priv->phy_node != node &&
> +			!of_phy_is_fixed_link(node))) {

[Severity: Medium]
The commit message says:

    of_phy_is_fixed_link() also returns true for managed = "in-band-status";
    give phy-handle precedence over it, like fec and gianfar.

Does this condition keep that precedence for bus registration?

priv->phy_node == node only happens when the fixed-link branch ran, and
of_phy_is_fixed_link(node) is already true there. So the test reduces to
"mdio_np || !of_phy_is_fixed_link(node)".

of_phy_is_fixed_link() in drivers/net/mdio/of_mdio.c returns true for any
managed value other than "auto":

	err = of_property_read_string(np, "managed", &managed);
	if (err == 0 && strcmp(managed, "auto") != 0)
		return true;

Consider a node with phy-handle, managed = "in-band-status", and the PHY
as a direct child of the MAC node with no "mdio" subnode. The
hisilicon,hisi-gmac-v1.yaml binding only forbids direct PHY children
when fixed-link is present, so this layout is allowed.

For that node of_mdiobus_register() is never called, so the PHY is never
created. hix5hd2_net_open() then fails here:

	phy = of_phy_connect(dev, priv->phy_node,
			     &hix5hd2_adjust_link, 0, priv->phy_mode);
	if (!phy) {
		...
		return -ENODEV;

Before this patch the bus was always registered on mdio_np ?: node, and
this layout worked. This configuration also leaves priv->bus NULL, which
leads to the remove issue below.

Would "mdio_np || priv->phy_node != node" be the intended test here?

> +		bus = devm_mdiobus_alloc(dev);
> +		if (!bus) {
> +			ret = -ENOMEM;
> +			of_node_put(mdio_np);
> +			goto out_phy_node;
> +		}
> +
> +		bus->priv = priv;
> +		bus->name = "hix5hd2_mii_bus";
> +		bus->read = hix5hd2_mdio_read;
> +		bus->write = hix5hd2_mdio_write;
> +		bus->parent = &pdev->dev;
> +		snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii",
> +			 dev_name(&pdev->dev));
> +		priv->bus = bus;

[ ... ]

> @@ -1294,6 +1314,8 @@ static void hix5hd2_dev_remove(struct platform_device *pdev)
>  	if (HAS_CAP_TSO(priv->hw_cap))
>  		hix5hd2_destroy_sg_desc_queue(priv);
>  	hix5hd2_destroy_hw_desc_queue(priv);
> +	if (priv->phy_node == pdev->dev.of_node)
> +		of_phy_deregister_fixed_link(pdev->dev.of_node);
>  	of_node_put(priv->phy_node);
>  }

[Severity: High]
Can hix5hd2_dev_remove() dereference a NULL priv->bus now?

Just above this hunk, remove still does:

	unregister_netdev(ndev);
	cancel_work_sync(&priv->tx_timeout_task);
	mdiobus_unregister(priv->bus);

With this patch, hix5hd2_dev_probe() only allocates the bus and sets
priv->bus inside the new conditional block. Take the fixed-link case
this patch adds support for, with no phy-handle and no "mdio" child.
Probe succeeds and priv->bus stays NULL, because the private area from
devm_alloc_etherdev() is zeroed.

On unbind or rmmod, mdiobus_unregister() dereferences bus right away:

	if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED))
		return;

The probe error path gained an "if (bus)" check. Does remove need the
same check on priv->bus?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126005524.4156940-1-mmyangfl%40gmail.com
Technical Details
Message-ID: <179574379856.3135.451399791466560621@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372400-linux-kernel-netdev=dewy.ru
References: <20261126005524.4156940-6-mmyangfl@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372400-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link
Date: Fri, 27 Nov 2026 01:43:18 +0000
Organization: Usenet Network
Message-ID: <179574379856.3135.451399791466560621@kernel.org>
References: <20261126005524.4156940-6-mmyangfl@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="612159"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QnEoMAEMYmYo8pFqJblIlQ1q2HQ= sha256:REK2UqPrV1FaQ3MeEyf5VfnAWjLkDnUR4qW4ya5Zhmg=
	sha1:5wf8SzZOjT6HYIHkHFEi/FfcxLk= sha256:Sf9tU5t9EGy01X4oPI310tjbjoizvostbFar2dKK1dE=
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 B69E4125F0E; Fri, 27 Nov 2026 04:43:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 GNULLf0_5FOc;
	Fri, 27 Nov 2026 04:43:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372400-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 79AE8125F0D; Fri, 27 Nov 2026 04:43:25 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 3968E2AA7D; Fri, 27 Nov 2026 01:43:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795743801;
	b=KvDGZ0WggWIzhD+24PAEB3fL4yoGdEDDr0Xm2Dc7jJbYicYNjPuciCde9YJmvde3SwLv
	 NAJVMLxkY5QfDB9cGpBWNefiRIM88qatuwSZdGE9kZmGVrkw8Ci7Cm4VkoqTgtaeZ04Gx
	 D2KgYdyc7530d6S62SnNqsTNaLQN+1cVFle0o/ClwVYlSsMhhGXFRIhFEMcwn6+MKqTPc
	 JRFSRjj99+ZGMfOYvgDM26MF8RxPytXWUL8/yQILD2zHx5Vn9p2OuMgY+4T16tzqmHgYd
	 2EBguI8ov7f3crSugAWRfj5w95NzMP3ZNoRJLqo7jSPx8V5Yy674fizHFh1FO7974jA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795743801;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=Y/ZQbh30QVryTCiZlteV2hYSBClLcTqEk7Mc1ddXGBE=;
	b=CcwHLOzKRvCA4zVJZe7m3cs4G8fyZPjbRlu523AVWBS8SXkagLBdR4oh8/Ni5OQ5fS5c
	 0niveVHpGfvDAluKGRp7nRx0JUn3TykeDIPtEmkswYgarofncTZmdOssNx35UEIS+9NAd
	 biB/3ocyRLFWlcinQY32tAZUQTX5yNi0X2IqPAy7K0nOLlKwT3fNkN/NCJs76gCzjuooj
	 MmdTmhrl39pb1nqatrokLG/FS8eswI0NVJ7y45+h/9ejjGdLnCkkg3+xnCZWns4VNSjBH
	 ThIeK3UreoNGebHnaHv2lGv/13peQd2tsJJWBOcvneQEVsxYRLz1kRys9brQ7qA1MtQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m9OOVRIm;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 11BAD606A321;
	Fri, 27 Nov 2026 01:43:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m9OOVRIm
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795743800;
	b=2KjAqcY7vHS7WjsfwV+pc/bjPUSp/OjgE0nH7Rf2kIpiNr2f+QFtQp48ev42jKa4fskH
	 Gbo6SBbBM6d9q2dblsWusg73Rm0VFtrd3ZHyDb85oupRc74UOiM6x/LasJNzKV7+9mFU4
	 XvcJ/lrsyo8d2h6J5lbYgrx979emzk3exp41cXkpDNs+zwJl6e6USNycBq55MThMK4UZW
	 EX6/IDVkmvAEJOKORXs0/RC6KJo/B1iJ8C8J/9KpxXA1aoSgMoLCg8TLdnCibPOZgzibT
	 nqwNPYSIbNBhiafBM43cIfb1aDzPL80TOjBovrvJjklxZPxLMfDHh6V9aPgMsRB7Iug==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795743800;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=Y/ZQbh30QVryTCiZlteV2hYSBClLcTqEk7Mc1ddXGBE=;
	b=5GBS+OXvPwhW+C+WZJ0DEuCxwYorwBElBTBQivW3cKGEb0ab3UT1oCuF6bSNfyLEXDCT
	 f/XgtBBwT/OaPv+6z8Vannvwy8NBjYxugE3UN5BfHj8EBjZlmL5pny01ZNbm0HDCOGQ1N
	 G9iqQP8AG97Cxb7mb7MZ4bRdjtwJDHrnPs0pyi6w+PKBG3YrW1HusOb8gW8BwcKqYAKKp
	 6Efjjuw6zomEjJ86KddwdoLPZcL6FYwd2nSdhyM208Xrs7UfNX1WT1jXIhHlNnjK28fxz
	 eW1ixJx56z96zkuxDhbK/ujvDsu9FAcLeexCLJn+bblMOjMI6kNMHF42YBoxWTEnDbg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m9OOVRIm;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 335FD606A31E;
	Fri, 27 Nov 2026 01:43:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B3A31F000C1;
	Fri, 27 Nov 2026 01:43:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795743799;
	bh=Y/ZQbh30QVryTCiZlteV2hYSBClLcTqEk7Mc1ddXGBE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=m9OOVRIm3/j5XNAoOLQcydd9DwOMZxWAAoo9RJWN88EJ7pZ9jO+AQgLoyWiA8WBKg
	 otKEKjIN0O9beYXaY8as7F/c4qESGjjgt7sJwXutVXu5i9eov03sbDdP50dxay26B4
	 aYaBF5MQ0fAhNp3nHUipV8QoCtofIPaBfcUMte7MklFIlNz9DaCL0ao4P0t3ZfIcpQ
	 1+SRJOo2uQoE/fBhQ+xNIW3mL9+NxsY8RJOW4u2G6CrfIhmo9uEw5Ed8G+AZx53bW2
	 VUHr8FU4AQ/GVMkmofn8fwkOrCaFTsgg4f7kYBfu2HNwuLm1aciOF/0xZ7xaQ2IrDE
	 7wR111cYEhnlA==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
 krzk+dt@kernel.org, conor+dt@kernel.org, shenjian15@huawei.com,
 shaojijie@huawei.com, devicetree@vger.kernel.org
X-In-Reply-To: <20261126005524.4156940-6-mmyangfl@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list