tun/tap: Add the missed return value check of register_netdevice_notifier
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Thu, 20 Jul 2017 09:41:34 +0000 (02:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Jul 2017 20:44:31 +0000 (13:44 -0700)
There is some codes of tun/tap module which did not check the return
value of register_netdevice_notifier. Add the check now.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c

index 3d4c24572ecdcda8ffdd47070ce75dcb625441da..32ad87345f5798498584d8dcfbda2f9ac993e619 100644 (file)
@@ -2598,8 +2598,16 @@ static int __init tun_init(void)
                goto err_misc;
        }
 
-       register_netdevice_notifier(&tun_notifier_block);
+       ret = register_netdevice_notifier(&tun_notifier_block);
+       if (ret) {
+               pr_err("Can't register netdevice notifier\n");
+               goto err_notifier;
+       }
+
        return  0;
+
+err_notifier:
+       misc_deregister(&tun_miscdev);
 err_misc:
        rtnl_link_unregister(&tun_link_ops);
 err_linkops: