[PATCH] vme: add missing put_device() after device_register() fails

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

 



From: "Emilio G. Cota" <cota@xxxxxxxxx>

put_device() must be called after device_register() fails,
since device_register() always initializes the refcount
on the device structure.

Signed-off-by: Emilio G. Cota <cota@xxxxxxxxx>
---
 drivers/vme/vme.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 95a9f71..5e6c7d7 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1366,26 +1366,27 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
 		err = device_register(&vdev->dev);
 		if (err)
 			goto err_reg;
 
 		if (vdev->dev.platform_data) {
 			list_add_tail(&vdev->drv_list, &drv->devices);
 			list_add_tail(&vdev->bridge_list, &bridge->devices);
 		} else
 			device_unregister(&vdev->dev);
 	}
 	return 0;
 
 err_reg:
+	put_device(&vdev->dev);
 	kfree(vdev);
 err_devalloc:
 	list_for_each_entry_safe(vdev, tmp, &drv->devices, drv_list) {
 		list_del(&vdev->drv_list);
 		list_del(&vdev->bridge_list);
 		device_unregister(&vdev->dev);
 	}
 	return err;
 }
 
 static int __vme_register_driver(struct vme_driver *drv, unsigned int ndevs)
 {
 	struct vme_bridge *bridge;
-- 
1.7.9.5

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux