[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] linux-2.6.18/scsiback: fix initialization error paths



scsiback_interface_exit() must not be called upon failure of
scsiback_interface_init().

Similarly, scsiback_xenbus_unregister() shouldn't be called when
scsiback_xenbus_init() failed. With this reference to it removed, the
function can be marked __exit (and its initialization counterpart
should have been __init from the beginning).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/drivers/xen/scsiback/scsiback.c
+++ b/drivers/xen/scsiback/scsiback.c
@@ -700,7 +700,7 @@ static int __init scsiback_init(void)
                pending_grant_handles[i] = SCSIBACK_INVALID_HANDLE;
 
        if (scsiback_interface_init() < 0)
-               goto out_of_kmem;
+               goto out_of_memory;
 
        INIT_LIST_HEAD(&pending_free);
 
@@ -708,15 +708,13 @@ static int __init scsiback_init(void)
                list_add_tail(&pending_reqs[i].free_list, &pending_free);
 
        if (scsiback_xenbus_init())
-               goto out_of_xenbus;
+               goto out_interface;
 
        scsiback_emulation_init();
 
        return 0;
 
-out_of_xenbus:
-       scsiback_xenbus_unregister();
-out_of_kmem:
+out_interface:
        scsiback_interface_exit();
 out_of_memory:
        kfree(pending_reqs);
--- a/drivers/xen/scsiback/xenbus.c
+++ b/drivers/xen/scsiback/xenbus.c
@@ -363,12 +363,12 @@ static DEFINE_XENBUS_DRIVER(scsiback, ,
        .otherend_changed       = scsiback_frontend_changed
 );
 
-int scsiback_xenbus_init(void)
+int __init scsiback_xenbus_init(void)
 {
        return xenbus_register_backend(&scsiback_driver);
 }
 
-void scsiback_xenbus_unregister(void)
+void __exit scsiback_xenbus_unregister(void)
 {
        xenbus_unregister_driver(&scsiback_driver);
 }



Attachment: xen-scsiback-init-error-paths.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.