Re: [PATCH net] macvlan: Return error on register_netdevice_notifier() failure

From: Eric Dumazet
Date: Thu Jul 25 2024 - 05:45:28 EST


On Wed, Jul 24, 2024 at 3:56 PM Shigeru Yoshida <syoshida@xxxxxxxxxx> wrote:
>
> register_netdevice_notifier() may fail, but macvlan_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.

>
> Fixes: b863ceb7ddce ("[NET]: Add macvlan driver")
> Signed-off-by: Shigeru Yoshida <syoshida@xxxxxxxxxx>
> ---
> drivers/net/macvlan.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 24298a33e0e9..ae2f1a8325a5 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -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
>