Skip to contentSkip to conversation

mctp: check register_netdevice_notifier() error in mctp_device_init()

PATCH Applied Minhong He 2 participants 2 messages Jul 20 – Jul 23

Subsystems (3)
lore
Share & tools
lore

Minhong He

author
#0 lore raw

PATCH v3 1/1 mctp: check register_netdevice_notifier() error in mctp_device_init()

mctp_device_init() handles errors from rtnl_af_register() and rtnl_register_many(), but ignores the return value of register_netdevice_notifier(). If notifier registration fails, init can still return success while the module is only partially initialized.

Check the notifier registration error and fail module init early.

Fixes 583be982d934 ("mctp: Add device handling and netlink interface")

---
v3:
- Correct Fixes tag to 583be982d934 (bug predates d51705614f66).
- No Cc:stable (unlikely init failure path; stable would also need d51705614f66 as a prereq on older trees).
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/

 net/mctp/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/mctp/device.c +3 -1
index 2c84df674669..822120e860c8 100644
@@ -536,7 +536,9 @@ int __init mctp_device_init(void)
 {
 	int err;
 
-	register_netdevice_notifier(&mctp_dev_nb);
+	err = register_netdevice_notifier(&mctp_dev_nb);
+	if (err)
+		return err;
 
 	err = rtnl_af_register(&mctp_af_ops);
 	if (err)
Signature · 1 line
2.25.1
#1 lore raw
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 Mon, 20 Jul 2026 15:25:18 +0800 you wrote:

mctp_device_init() handles errors from rtnl_af_register() and rtnl_register_many(), but ignores the return value of register_netdevice_notifier(). If notifier registration fails, init can still return success while the module is only partially initialized.

Check the notifier registration error and fail module init early.

[...]

Here is the summary with links:
- [net,v3] mctp: check register_netdevice_notifier() error in mctp_device_init()

    https://git.kernel.org/netdev/net/c/d9a33cadc70a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html