Skip to contentSkip to conversation

net: vrf: check register_netdevice_notifier() error in vrf_init_module()

PATCH Applied Minhong He 4 participants 5 messages Aug 3 – Aug 5

Subsystems (3)
lore
Share & tools
lore

Minhong He

author
#0 lore raw

PATCH 1/1 net: vrf: check register_netdevice_notifier() error in vrf_init_module()

vrf_init_module() ignores register_netdevice_notifier() errors and continues module initialization, which can leave VRF loaded without its netdev notifier registered.

Check the error and fail module initialization early.

---
 drivers/net/vrf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/vrf.c +3 -1
index 46209917ae4d..a0557a3a7026 100644
@@ -1932,7 +1932,9 @@ static int __init vrf_init_module(void)
 {
 	int rc;
 
-	register_netdevice_notifier(&vrf_notifier_block);
+	rc = register_netdevice_notifier(&vrf_notifier_block);
+	if (rc < 0)
+		return rc;
 
 	rc = register_pernet_subsys(&vrf_net_ops);
 	if (rc < 0)
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Minhong He

vrf_init_module() ignores register_netdevice_notifier() errors and continues module initialization, which can leave VRF loaded without its netdev notifier registered.

Check the error and fail module initialization early.

Fixes 193125dbd8eb ("net: Introduce VRF device driver")
Quoted 10 lines
---
 drivers/net/vrf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/vrf.c +0 -0
index 46209917ae4d..a0557a3a7026 100644

drivers/net/vrf.c static int __init vrf_init_module(void) · line 1940

Quoted 10 lines
drivers/net/vrf.c +3 -1
@@ -1932,7 +1932,9 @@ static int __init vrf_init_module(void)
 {
 	int rc;
 
-	register_netdevice_notifier(&vrf_notifier_block);
+	rc = register_netdevice_notifier(&vrf_notifier_block);
+	if (rc < 0)
+		return rc;
 
 	rc = register_pernet_subsys(&vrf_net_ops);
 	if (rc < 0)
maintainer
#2 lore raw
Quoted 1 line · On Mon, 3 Aug 2026 10:59:47 -0600 David Ahern wrote:
Fixes 193125dbd8eb ("net: Introduce VRF device driver")

Thanks for the tag and the review!

In this case I'm going to skip and take this via net-next 'cause register_netdevice_notifier() is guaranteed not to fail today.

maintainer
#3 lore raw
Quoted 3 lines · Jakub Kicinski

In this case I'm going to skip and take this via net-next 'cause register_netdevice_notifier() is guaranteed not to fail today.

considered that response, so it works for me.

#4 lore raw
In reply to Minhong He
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 3 Aug 2026 17:00:02 +0800 you wrote:

vrf_init_module() ignores register_netdevice_notifier() errors and continues module initialization, which can leave VRF loaded without its netdev notifier registered.

Check the error and fail module initialization early.

[...]

Here is the summary with links:
- [net] net: vrf: check register_netdevice_notifier() error in vrf_init_module()

    https://git.kernel.org/netdev/net-next/c/ac072a89cba2

You are awesome, thank you!

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