Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
@ 2026-10-16 11:04 Jijie Shao
  2026-10-16 11:09 ` netdev-bot+sinfo
  2026-10-16 12:26 ` Daniel Machon
  0 siblings, 2 replies; 4+ messages in thread
From: Jijie Shao @ 2026-10-16 11:04 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev
  Cc: shenjian15, liuyonglong, chenhao418, yangshuaisong, ningwei15,
	shiyongbang, fengzheng6, netdev, linux-kernel, shaojijie

The driver assigns netdev_ops after hbg_init(), but hbg_init() calls
hbg_mdio_init() -> hbg_phy_connect() -> phy_connect_direct() ->
phy_attach_direct() -> phy_link_topo_add_phy(), which invokes
netdev_need_ops_lock(). With CONFIG_NET_SHAPER enabled, this function
dereferences dev->netdev_ops->net_shaper_ops. Since netdev_ops is still
NULL at this point, a NULL pointer dereference occurs.

Move the netdev_ops assignment before hbg_init() so that
netdev_need_ops_lock() can safely access netdev_ops during PHY
attachment.

Fixes: ff4edac6e9bd ("net: hibmcge: Implement some .ndo functions")
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
index 66792e2b0fad..a518dc66d9ef 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
@@ -448,6 +448,7 @@ static int hbg_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		return ret;
 
+	netdev->netdev_ops = &hbg_netdev_ops;
 	ret = hbg_init(priv);
 	if (ret)
 		return ret;
@@ -460,7 +461,6 @@ static int hbg_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	netdev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
 	netdev->max_mtu = priv->dev_specs.max_mtu;
 	netdev->min_mtu = priv->dev_specs.min_mtu;
-	netdev->netdev_ops = &hbg_netdev_ops;
 	netdev->watchdog_timeo = 5 * HZ;
 
 	hbg_hw_set_mtu(priv, ETH_DATA_LEN);

base-commit: 191aa41548b2d2b6af534a6d5cf84a552435c74c
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
  2026-10-16 11:04 [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference Jijie Shao
@ 2026-10-16 11:09 ` netdev-bot+sinfo
  2026-10-16 11:55   ` Jijie Shao
  2026-10-16 12:26 ` Daniel Machon
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-10-16 11:09 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	liuyonglong, chenhao418, yangshuaisong, ningwei15, shiyongbang,
	fengzheng6, netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
  2026-10-16 11:09 ` netdev-bot+sinfo
@ 2026-10-16 11:55   ` Jijie Shao
  0 siblings, 0 replies; 4+ messages in thread
From: Jijie Shao @ 2026-10-16 11:55 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: shaojijie, davem, edumazet, kuba, pabeni, andrew+netdev,
	shenjian15, liuyonglong, chenhao418, yangshuaisong, ningwei15,
	shiyongbang, fengzheng6, netdev, linux-kernel


on 2026/10/16 19:09, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
>   - How the issue was discovered, e.g. hit in production, hit during
>     development, syzbot report, manual code inspection, LLM or static
>     analysis tool scan.
>
>   - What hardware the change was tested on. For driver fixes please
>     mention the device (and if relevant firmware version) used for
>     testing, or say that the change was not tested on real hardware.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account. If the series needs another revision for
> other reasons, please include the information in the commit messages
> then.
>
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.

Hi, The issue was hit and verified on an evaluation board.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
  2026-10-16 11:04 [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference Jijie Shao
  2026-10-16 11:09 ` netdev-bot+sinfo
@ 2026-10-16 12:26 ` Daniel Machon
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Machon @ 2026-10-16 12:26 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	liuyonglong, chenhao418, yangshuaisong, ningwei15, shiyongbang,
	fengzheng6, netdev, linux-kernel

> The driver assigns netdev_ops after hbg_init(), but hbg_init() calls
> hbg_mdio_init() -> hbg_phy_connect() -> phy_connect_direct() ->
> phy_attach_direct() -> phy_link_topo_add_phy(), which invokes
> netdev_need_ops_lock(). With CONFIG_NET_SHAPER enabled, this function
> dereferences dev->netdev_ops->net_shaper_ops. Since netdev_ops is still
> NULL at this point, a NULL pointer dereference occurs.
> 
> Move the netdev_ops assignment before hbg_init() so that
> netdev_need_ops_lock() can safely access netdev_ops during PHY
> attachment.

Reviewed-by: Daniel Machon <daniel.machon@microchip.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-16 12:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 11:04 [PATCH net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference Jijie Shao
2026-10-16 11:09 ` netdev-bot+sinfo
2026-10-16 11:55   ` Jijie Shao
2026-10-16 12:26 ` Daniel Machon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox