]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
netfront: Unregister inetdev notifiers on failure
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 2 Mar 2009 11:06:52 +0000 (11:06 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 2 Mar 2009 11:06:52 +0000 (11:06 +0000)
If you attempt to modprobe the pv-on-hvm netfront driver on a machine
not running under Xen (say, bare-metal, or under another hypervisor), the
netfront code correctly returns an ENODEV and fails to load.  However, if you
then shutdown that machine, you will oops while tearing down the network.
This is because we forget to unregister the the inetaddr_notifier on failure,
and so the kernel takes a fatal page fault.  The attached patch just unregisters
the notifier on failure, and solves the problem for me.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
drivers/xen/netfront/netfront.c

index 8e51aa7250f6f2b758629f2419cb1b4b144ebe0e..67f34246a243ecb22d159719ec25381d2099a6f9 100644 (file)
@@ -2199,6 +2199,8 @@ static struct xenbus_driver netfront_driver = {
 
 static int __init netif_init(void)
 {
+       int err;
+
        if (!is_running_on_xen())
                return -ENODEV;
 
@@ -2220,7 +2222,13 @@ static int __init netif_init(void)
        (void)register_inetaddr_notifier(&notifier_inetdev);
 #endif
 
-       return xenbus_register_frontend(&netfront_driver);
+       err = xenbus_register_frontend(&netfront_driver);
+       if (err) {
+#ifdef CONFIG_INET
+               unregister_inetaddr_notifier(&notifier_inetdev);
+#endif
+       }
+       return err;
 }
 module_init(netif_init);