WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] usbback: check return value of xenbus

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] usbback: check return value of xenbus_register in usbback_init().
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Oct 2009 02:40:21 -0700
Delivery-date: Fri, 23 Oct 2009 02:41:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1256288808 -3600
# Node ID b4dc4f05c425951e5fa6456292f8ef329d34c3c9
# Parent  cd453b4804b95fe9198d79aff60799b36b713060
usbback: check return value of xenbus_register in usbback_init().

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@xxxxxxxxxxxxxx>
---
 drivers/xen/usbback/usbback.c |   31 +++++++++++++++++++------------
 drivers/xen/usbback/usbback.h |    2 +-
 drivers/xen/usbback/usbstub.c |    2 +-
 drivers/xen/usbback/xenbus.c  |   12 ++++++------
 4 files changed, 27 insertions(+), 20 deletions(-)

diff -r cd453b4804b9 -r b4dc4f05c425 drivers/xen/usbback/usbback.c
--- a/drivers/xen/usbback/usbback.c     Mon Oct 12 12:57:55 2009 +0100
+++ b/drivers/xen/usbback/usbback.c     Fri Oct 23 10:06:48 2009 +0100
@@ -1093,11 +1093,9 @@ static int __init usbback_init(void)
 static int __init usbback_init(void)
 {
        int i, mmap_pages;
+       int err = 0;
 
        if (!is_running_on_xen())
-               return -ENODEV;
-
-       if (usbstub_init())
                return -ENODEV;
 
        mmap_pages = usbif_reqs * USBIF_MAX_SEGMENTS_PER_REQUEST;
@@ -1107,8 +1105,10 @@ static int __init usbback_init(void)
                        mmap_pages, GFP_KERNEL);
        pending_pages = alloc_empty_pages_and_pagevec(mmap_pages);
 
-       if (!pending_reqs || !pending_grant_handles || !pending_pages)
-               goto out_of_memory;
+       if (!pending_reqs || !pending_grant_handles || !pending_pages) {
+               err = -ENOMEM;
+               goto out_mem;
+       }
 
        for (i = 0; i < mmap_pages; i++)
                pending_grant_handles[i] = USBBACK_INVALID_HANDLE;
@@ -1119,16 +1119,23 @@ static int __init usbback_init(void)
        for (i = 0; i < usbif_reqs; i++)
                list_add_tail(&pending_reqs[i].free_list, &pending_free);
 
-       usbback_xenbus_init();
+       err = usbstub_init();
+       if (err)
+               goto out_mem;
+
+       err = usbback_xenbus_init();
+       if (err)
+               goto out_xenbus;
 
        return 0;
 
- out_of_memory:
-        kfree(pending_reqs);
-        kfree(pending_grant_handles);
-        free_empty_pages_and_pagevec(pending_pages, mmap_pages);
-        printk("%s: out of memory\n", __FUNCTION__);
-        return -ENOMEM;
+out_xenbus:
+       usbstub_exit();
+out_mem:
+       kfree(pending_reqs);
+       kfree(pending_grant_handles);
+       free_empty_pages_and_pagevec(pending_pages, mmap_pages);
+       return err;
 }
 
 static void __exit usbback_exit(void)
diff -r cd453b4804b9 -r b4dc4f05c425 drivers/xen/usbback/usbback.h
--- a/drivers/xen/usbback/usbback.h     Mon Oct 12 12:57:55 2009 +0100
+++ b/drivers/xen/usbback/usbback.h     Fri Oct 23 10:06:48 2009 +0100
@@ -145,7 +145,7 @@ int usbif_map(usbif_t *usbif, unsigned l
        } while (0)
 
 usbif_t *find_usbif(domid_t domid, unsigned int handle);
-void usbback_xenbus_init(void);
+int usbback_xenbus_init(void);
 void usbback_xenbus_exit(void);
 struct vusb_port_id *find_portid_by_busid(const char *busid);
 struct vusb_port_id *find_portid(const domid_t domid,
diff -r cd453b4804b9 -r b4dc4f05c425 drivers/xen/usbback/usbstub.c
--- a/drivers/xen/usbback/usbstub.c     Mon Oct 12 12:57:55 2009 +0100
+++ b/drivers/xen/usbback/usbstub.c     Fri Oct 23 10:06:48 2009 +0100
@@ -317,7 +317,7 @@ out:
        return err;
 }
 
-void __exit usbstub_exit(void)
+void usbstub_exit(void)
 {
        driver_remove_file(&usbback_usb_driver.driver,
                                &driver_attr_port_ids);
diff -r cd453b4804b9 -r b4dc4f05c425 drivers/xen/usbback/xenbus.c
--- a/drivers/xen/usbback/xenbus.c      Mon Oct 12 12:57:55 2009 +0100
+++ b/drivers/xen/usbback/xenbus.c      Fri Oct 23 10:06:48 2009 +0100
@@ -327,12 +327,12 @@ static struct xenbus_driver usbback_driv
        .remove = usbback_remove,
 };
 
-void usbback_xenbus_init(void)
-{
-       xenbus_register_backend(&usbback_driver);
-}
-
-void usbback_xenbus_exit(void)
+int __init usbback_xenbus_init(void)
+{
+       return xenbus_register_backend(&usbback_driver);
+}
+
+void __exit usbback_xenbus_exit(void)
 {
        xenbus_unregister_driver(&usbback_driver);
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] usbback: check return value of xenbus_register in usbback_init()., Xen patchbot-linux-2.6.18-xen <=