[PATCH 23/30] staging/vme_user: fix usage of the slave resources after they've been freed

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Emilio G. Cota
Date: Monday, October 25, 2010 - 6:11 pm

From: Emilio G. Cota <cota@braap.org>

buf_unalloc() frees the memory buffers allocated with vme_alloc_consistent.
The associated VME resource is needed in both vme_alloc_consistent and
vme_free_consistent; however the slave VME resources are being freed before
the calls to vme_free_consistent are made, which means the buffers
are never returned.

Fix this by freeing the VME resources only after the consistent buffers have
been returned.

Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 drivers/staging/vme/devices/vme_user.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 5def455..95c22ff 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -826,8 +826,8 @@ err_master:
 err_slave:
 	while (i > SLAVE_MINOR) {
 		i--;
-		vme_slave_free(image[i].resource);
 		buf_unalloc(i);
+		vme_slave_free(image[i].resource);
 	}
 err_class:
 	cdev_del(vme_user_cdev);
@@ -852,8 +852,8 @@ static int __devexit vme_user_remove(struct device *dev, int cur_bus, int cur_sl
 
 	for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) {
 		vme_slave_set(image[i].resource, 0, 0, 0, 0, VME_A32, 0);
-		vme_slave_free(image[i].resource);
 		buf_unalloc(i);
+		vme_slave_free(image[i].resource);
 	}
 
 	/* Unregister device driver */
-- 
1.7.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 03/30] staging/vme_user: remove unreachable line, Emilio G. Cota, (Mon Oct 25, 6:10 pm)
[PATCH 08/30] staging/vme/tsi148: fix warning in free_irq, Emilio G. Cota, (Mon Oct 25, 6:10 pm)
[PATCH 10/30] staging/vme/tsi148: remove unreachable line, Emilio G. Cota, (Mon Oct 25, 6:10 pm)
[PATCH 23/30] staging/vme_user: fix usage of the slave res ..., Emilio G. Cota, (Mon Oct 25, 6:11 pm)
[PATCH 27/30] staging/vme: rework the bus model, Emilio G. Cota, (Mon Oct 25, 6:11 pm)
[PATCH 28/30] staging/vme: convert vme_* users to vme_*_ng, Emilio G. Cota, (Mon Oct 25, 6:11 pm)
[PATCH 30/30] staging/vme: remove _ng suffixes, Emilio G. Cota, (Mon Oct 25, 6:11 pm)
Re: [PATCH 27/30] staging/vme: rework the bus model, Emilio G. Cota, (Wed Nov 3, 9:16 pm)
[PATCH 00/17] Series short description, Martyn Welch, (Fri Nov 12, 4:13 am)
[PATCH 03/17] staging/vme_user: remove unreachable line, Martyn Welch, (Fri Nov 12, 4:14 am)
Re: [PATCH 00/17] Series short description, Martyn Welch, (Fri Nov 12, 4:23 am)
Re: [PATCH 00/17] Series short description, Emilio G. Cota, (Fri Nov 12, 8:11 am)
Re: [PATCH 00/17] Series short description, Martyn Welch, (Fri Nov 12, 8:52 am)
Re: [PATCH 00/17] Series short description, Greg KH, (Tue Nov 16, 12:40 pm)