macvlan: Return error on register_netdevice_notifier() failure
Subsystems (2)
PATCH 1/1 macvlan: Return error on register_netdevice_notifier() failure
register_netdevice_notifier() may fail, but macvlan_init_module() does not handle the failure. Handle the failure by returning an error.
--- drivers/net/macvlan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/macvlan.c +3 -1
@@ -1849,7 +1849,9 @@ static int __init macvlan_init_module(void) {int err; -register_netdevice_notifier (&macvlan_notifier_block); + err =register_netdevice_notifier (&macvlan_notifier_block); +if (err <0 ) +return err; err =macvlan_link_register (&macvlan_link_ops);if (err <0 )
Signature · 1 line
2.45.2
Quoted 5 lines · Shigeru Yoshida
register_netdevice_notifier()may fail, butmacvlan_init_module()does not handle the failure. Handle the failure by returning an error.Fixes b863ceb7ddce ("[NET]: Add macvlan driver")Signed-off-by Shigeru Yoshida <[email protected]>
Quoted 3 lines · Shigeru Yoshida
register_netdevice_notifier()may fail, butmacvlan_init_module()does not handle the failure. Handle the failure by returning an error.
How could this fail exactly ? Please provide details, because I do not think it can.
Quoted 25 lines
Fixes b863ceb7ddce ("[NET]: Add macvlan driver")Signed-off-by Shigeru Yoshida <[email protected]>--- drivers/net/macvlan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macvlan.c +3
-2@@ -1849,7 +1849,9 @@ static int __init macvlan_init_module(void) {int err; -register_netdevice_notifier (&macvlan_notifier_block); + err =register_netdevice_notifier (&macvlan_notifier_block); +if (err <0 ) +return err; err =macvlan_link_register (&macvlan_link_ops);if (err <0 ) --2.45.2
Paolo Abeni
maintainerQuoted 7 lines · Eric Dumazet
Quoted 3 lines · Shigeru Yoshida
register_netdevice_notifier()may fail, butmacvlan_init_module()does not handle the failure. Handle the failure by returning an error.How could this fail exactly ? Please provide details, because I do not think it can.
Yup, it looks like the registration can't fail for macvlan.
It's better to avoid adding unneeded checks, to reduce noise on the tree, keep stable backport easy, etc.
Thanks,
Paolo
Quoted 9 lines · Paolo Abeni
Quoted 5 lines · Eric Dumazet
Quoted 3 lines · Shigeru Yoshida
register_netdevice_notifier()may fail, butmacvlan_init_module()does not handle the failure. Handle the failure by returning an error.
Quoted 7 lines
Quoted 2 lines
How could this fail exactly ? Please provide details, because I do not think it can.
Yup, it looks like the registration can't fail for macvlan.
It's better to avoid adding unneeded checks, to reduce noise on the tree, keep stable backport easy, etc.
Shigeru, you could send a debug patch when net-next reopens next week, so that we do not get another attempt
on fixing a non-existent bug.
drivers/net/macvlan.c +0 -0
100644
drivers/net/macvlan.c +2 -1
@@ -1849,7 +1849,8 @@ static int __init macvlan_init_module(void) {int err; -register_netdevice_notifier (&macvlan_notifier_block); + err =register_netdevice_notifier (&macvlan_notifier_block); +DEBUG_NET_WARN_ON_ONCE (err <0 ); err =macvlan_link_register (&macvlan_link_ops);if (err <0 )
Hi Eric, Paolo,
Quoted 10 lines · Eric Dumazet
Quoted 9 lines · Paolo Abeni
Quoted 5 lines · Eric Dumazet
Quoted 3 lines · Shigeru Yoshida
register_netdevice_notifier()may fail, butmacvlan_init_module()does not handle the failure. Handle the failure by returning an error.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
How could this fail exactly ? Please provide details, because I do not think it can.
Yup, it looks like the registration can't fail for macvlan.
It's better to avoid adding unneeded checks, to reduce noise on the tree, keep stable backport easy, etc.
Thank you for your comments, and it's my bad, sorry.
I happened to look at macvlan's code and found this. I compared this with others like macvtap and I assumed that registering for notifier needs error handling without checking carefully.
Quoted 3 lines
Shigeru, you could send a debug patch when net-next reopens next week, so that we do not get another attempt
on fixing a non-existent bug.
I think we don't need this DEBUG_NET_WARN_ON_ONCE() because it makes the source code a little messy.
Next time I find something, I'll be more careful.
Thanks,
Shigeru
Quoted 16 lines
drivers/net/macvlan.c +0
-0100644
drivers/net/macvlan.c +2
-1@@ -1849,7 +1849,8 @@ static int __init macvlan_init_module(void) {int err; -register_netdevice_notifier (&macvlan_notifier_block); + err =register_netdevice_notifier (&macvlan_notifier_block); +DEBUG_NET_WARN_ON_ONCE (err <0 ); err =macvlan_link_register (&macvlan_link_ops);if (err <0 )