powerpc/pci/rpadlpar: Fix device reference leaks
[pandora-kernel.git] / drivers / pci / hotplug / rpadlpar_core.c
index 1d002b1..9de3f7c 100644 (file)
@@ -18,6 +18,7 @@
 #undef DEBUG
 
 #include <linux/init.h>
+#include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
@@ -258,8 +259,13 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)
 
 static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
 {
-       if (vio_find_node(dn))
+       struct vio_dev *vio_dev;
+
+       vio_dev = vio_find_node(dn);
+       if (vio_dev) {
+               put_device(&vio_dev->dev);
                return -EINVAL;
+       }
 
        if (!vio_register_device_node(dn)) {
                printk(KERN_ERR
@@ -335,6 +341,9 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
                return -EINVAL;
 
        vio_unregister_device(vio_dev);
+
+       put_device(&vio_dev->dev);
+
        return 0;
 }