net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
Subsystems (4)
Jijie Shao
maintainerPATCH 1/1 net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
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.
--- drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +1 -1
@@ -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
Signature · 1 line
2.43.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
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.
Jijie Shao
maintainerQuoted 13 lines · on 2026/10/16 19:09, [email protected] 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.
Quoted 8 lines
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.
Quoted 10 lines
The driver assigns
netdev_opsafterhbg_init(), buthbg_init()callshbg_mdio_init()->hbg_phy_connect()->phy_connect_direct()->phy_attach_direct()->phy_link_topo_add_phy(), which invokesnetdev_need_ops_lock(). WithCONFIG_NET_SHAPERenabled, this function dereferencesdev->netdev_ops->net_shaper_ops. Sincenetdev_opsis still NULL at this point, a NULL pointer dereference occurs.Move the
netdev_opsassignment beforehbg_init()so thatnetdev_need_ops_lock()can safely accessnetdev_opsduring PHY attachment.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 16 Oct 2026 19:04:21 +0800 you wrote:
The driver assigns
netdev_opsafterhbg_init(), buthbg_init()callshbg_mdio_init()->hbg_phy_connect()->phy_connect_direct()->phy_attach_direct()->phy_link_topo_add_phy(), which invokesnetdev_need_ops_lock(). WithCONFIG_NET_SHAPERenabled, this function dereferencesdev->netdev_ops->net_shaper_ops. Sincenetdev_opsis still NULL at this point, a NULL pointer dereference occurs.[...]
Here is the summary with links:
- [net] net: hibmcge: set netdev_ops before hbg_init() to fix NULL pointer dereference
https://git.kernel.org/netdev/net/c/9b8ae9aaa1b8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html