[PATCH 05/17] staging/vme/tsi148: use list_for_each_safe whendeleting resources in .remove

From: Martyn Welch
Date: Fri Nov 12 2010 - 06:14:42 EST


From: Emilio G. Cota <cota@xxxxxxxxx>

This fixes an oops when removing the module.

Signed-off-by: Emilio G. Cota <cota@xxxxxxxxx>
Acked-by: Martyn Welch <martyn.welch@xxxxxx>
---

drivers/staging/vme/bridges/vme_tsi148.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
index 1cba1fa..5c25cd8 100644
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -2531,6 +2531,7 @@ err_struct:
static void tsi148_remove(struct pci_dev *pdev)
{
struct list_head *pos = NULL;
+ struct list_head *tmplist;
struct vme_master_resource *master_image;
struct vme_slave_resource *slave_image;
struct vme_dma_resource *dma_ctrlr;
@@ -2589,21 +2590,21 @@ static void tsi148_remove(struct pci_dev *pdev)
tsi148_crcsr_exit(tsi148_bridge, pdev);

/* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->dma_resources) {
+ list_for_each_safe(pos, tmplist, &tsi148_bridge->dma_resources) {
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
list_del(pos);
kfree(dma_ctrlr);
}

/* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->slave_resources) {
+ list_for_each_safe(pos, tmplist, &tsi148_bridge->slave_resources) {
slave_image = list_entry(pos, struct vme_slave_resource, list);
list_del(pos);
kfree(slave_image);
}

/* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->master_resources) {
+ list_for_each_safe(pos, tmplist, &tsi148_bridge->master_resources) {
master_image = list_entry(pos, struct vme_master_resource,
list);
list_del(pos);


--
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms | Wales (3828642) at 100
T +44(0)127322748 | Barbirolli Square, Manchester,
E martyn.welch@xxxxxx | M2 3AB VAT:GB 927559189
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/