Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[linux-2.6-block.git] / drivers / virtio / virtio_pci_common.c
index 1c4797e53f686b03323e4316d443c256854268dc..48d4d1cf1cb63f7b67f58f17e3d7874d14a00b09 100644 (file)
@@ -513,7 +513,7 @@ static void virtio_pci_release_dev(struct device *_d)
 static int virtio_pci_probe(struct pci_dev *pci_dev,
                            const struct pci_device_id *id)
 {
-       struct virtio_pci_device *vp_dev;
+       struct virtio_pci_device *vp_dev, *reg_dev = NULL;
        int rc;
 
        /* allocate our structure and fill it out */
@@ -551,6 +551,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
        pci_set_master(pci_dev);
 
        rc = register_virtio_device(&vp_dev->vdev);
+       reg_dev = vp_dev;
        if (rc)
                goto err_register;
 
@@ -564,7 +565,10 @@ err_register:
 err_probe:
        pci_disable_device(pci_dev);
 err_enable_device:
-       kfree(vp_dev);
+       if (reg_dev)
+               put_device(&vp_dev->vdev.dev);
+       else
+               kfree(vp_dev);
        return rc;
 }