[PATCH] staging: vme_user: fix bugs in vme_user_probe

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

 



Signed-off-by: Raja Naresh <rajanaresh89@xxxxxxxxx>
---
 drivers/staging/vme/devices/vme_user.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index a571173..0929c33 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -736,7 +736,7 @@ static int __devinit vme_user_probe(struct device *dev, int cur_bus,
 			image[i].pci_buf = 0;
 			vme_slave_free(image[i].resource);
 			err = -ENOMEM;
-			goto err_slave;
+			goto err_slave_alloc;
 		}
 	}
 
@@ -803,13 +803,10 @@ static int __devinit vme_user_probe(struct device *dev, int cur_bus,
 
 	return 0;
 
-	/* Ensure counter set correcty to destroy all sysfs devices */
-	i = VME_DEVS;
 err_sysfs:
-	while (i > 0) {
-		i--;
+	while (--i >= 0)
 		device_destroy(vme_user_sysfs_class, MKDEV(VME_MAJOR, i));
-	}
+
 	class_destroy(vme_user_sysfs_class);
 
 	/* Ensure counter set correcty to unalloc all master windows */
@@ -818,18 +815,17 @@ err_master_buf:
 	for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++)
 		kfree(image[i].kern_buf);
 err_master:
-	while (i > MASTER_MINOR) {
-		i--;
+	while (--i >= MASTER_MINOR)
 		vme_master_free(image[i].resource);
-	}
-
-	/*
+      	/*
 	 * Ensure counter set correcty to unalloc all slave windows and buffers
 	 */
 	i = SLAVE_MAX + 1;
+err_slave_alloc:
+	if (i != (SLAVE_MAX + 1))
+		vme_slave_free(image[i].resource);
 err_slave:
-	while (i > SLAVE_MINOR) {
-		i--;
+	while (--i >= SLAVE_MINOR) {
 		buf_unalloc(i);
 		vme_slave_free(image[i].resource);
 	}
-- 
1.6.3.3

_______________________________________________
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