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-devel

Re: [Xen-devel] [PATCH] pciback: check function return values

To: "Keir Fraser" <keir@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] pciback: check function return values
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Wed, 28 Mar 2007 14:53:27 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 28 Mar 2007 06:51:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C2302EFD.C619%keir@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <460A7D47.76E4.0078.0@xxxxxxxxxx> <C2302EFD.C619%keir@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
>>> Keir Fraser <keir@xxxxxxxxxxxxx> 28.03.07 15:41 >>>
>On 28/3/07 13:35, "Jan Beulich" <jbeulich@xxxxxxxxxx> wrote:
>
>> .. of functions declared with __must_check post-2.6.18.
>> 
>> (As a note - I'm getting the impression that when used as a module, pciback
>> appears to have a number of memory leaks).
>> 
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
>
>Where is the mystery pciback_exit() function defined? You use it but don't
>provide an implementation.

Huh, sorry, unrefreshed patch. Thanks for catching this. Here's to proper one.

Index: head-2007-03-19/drivers/xen/pciback/conf_space_header.c
===================================================================
--- head-2007-03-19.orig/drivers/xen/pciback/conf_space_header.c        
2007-03-21 10:18:08.000000000 +0100
+++ head-2007-03-19/drivers/xen/pciback/conf_space_header.c     2007-03-28 
11:50:57.000000000 +0200
@@ -20,11 +20,15 @@ struct pci_bar_info {
 
 static int command_write(struct pci_dev *dev, int offset, u16 value, void 
*data)
 {
+       int err;
+
        if (!dev->is_enabled && is_enable_cmd(value)) {
                if (unlikely(verbose_request))
                        printk(KERN_DEBUG "pciback: %s: enable\n",
                               pci_name(dev));
-               pci_enable_device(dev);
+               err = pci_enable_device(dev);
+               if (err)
+                       return err;
        } else if (dev->is_enabled && !is_enable_cmd(value)) {
                if (unlikely(verbose_request))
                        printk(KERN_DEBUG "pciback: %s: disable\n",
@@ -44,7 +48,13 @@ static int command_write(struct pci_dev 
                        printk(KERN_DEBUG
                               "pciback: %s: enable memory-write-invalidate\n",
                               pci_name(dev));
-               pci_set_mwi(dev);
+               err = pci_set_mwi(dev);
+               if (err) {
+                       printk(KERN_WARNING
+                              "pciback: %s: cannot enable 
memory-write-invalidate (%d)\n",
+                              pci_name(dev), err);
+                       value &= ~PCI_COMMAND_INVALIDATE;
+               }
        }
 
        return pci_write_config_word(dev, offset, value);
Index: head-2007-03-19/drivers/xen/pciback/pci_stub.c
===================================================================
--- head-2007-03-19.orig/drivers/xen/pciback/pci_stub.c 2007-03-19 
15:26:06.000000000 +0100
+++ head-2007-03-19/drivers/xen/pciback/pci_stub.c      2007-03-28 
13:34:33.000000000 +0200
@@ -805,6 +805,18 @@ static ssize_t permissive_show(struct de
 
 DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show, permissive_add);
 
+static void pcistub_exit(void)
+{
+       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
+       driver_remove_file(&pciback_pci_driver.driver,
+                          &driver_attr_remove_slot);
+       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots);
+       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks);
+       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive);
+
+       pci_unregister_driver(&pciback_pci_driver);
+}
+
 static int __init pcistub_init(void)
 {
        int pos = 0;
@@ -845,12 +857,23 @@ static int __init pcistub_init(void)
        if (err < 0)
                goto out;
 
-       driver_create_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
-       driver_create_file(&pciback_pci_driver.driver,
-                          &driver_attr_remove_slot);
-       driver_create_file(&pciback_pci_driver.driver, &driver_attr_slots);
-       driver_create_file(&pciback_pci_driver.driver, &driver_attr_quirks);
-       driver_create_file(&pciback_pci_driver.driver, &driver_attr_permissive);
+       err = driver_create_file(&pciback_pci_driver.driver,
+                                &driver_attr_new_slot);
+       if (!err)
+               err = driver_create_file(&pciback_pci_driver.driver,
+                                        &driver_attr_remove_slot);
+       if (!err)
+               err = driver_create_file(&pciback_pci_driver.driver,
+                                        &driver_attr_slots);
+       if (!err)
+               err = driver_create_file(&pciback_pci_driver.driver,
+                                        &driver_attr_quirks);
+       if (!err)
+               err = driver_create_file(&pciback_pci_driver.driver,
+                                        &driver_attr_permissive);
+
+       if (err)
+               pcistub_exit();
 
       out:
        return err;
@@ -887,23 +910,17 @@ static int __init pciback_init(void)
 #endif
 
        pcistub_init_devices_late();
-       pciback_xenbus_register();
+       err = pciback_xenbus_register();
+       if (err)
+               pcistub_exit();
 
-       return 0;
+       return err;
 }
 
 static void __exit pciback_cleanup(void)
 {
        pciback_xenbus_unregister();
-
-       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
-       driver_remove_file(&pciback_pci_driver.driver,
-                          &driver_attr_remove_slot);
-       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots);
-       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks);
-       driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive);
-
-       pci_unregister_driver(&pciback_pci_driver);
+       pcistub_exit();
 }
 
 module_init(pciback_init);


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

<Prev in Thread] Current Thread [Next in Thread>