[PATCH] ioremap balanced with iounmap for drivers/sbus

From: Amol Lad
Date: Wed Sep 27 2006 - 05:40:38 EST


ioremap must be balanced by an iounmap and failing to do so can result
in a memory leak.

Tested (compilation only) with:
- Modifying arch/i386/Kconfig and other Makefiles to make sure that the
changed file is compiling ok.

Signed-off-by: Amol Lad <amol@xxxxxxxxxxxxxxxxxxx>
---
vfc_dev.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletion(-)
---
diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff linux-2.6.18-orig/drivers/sbus/char/vfc_dev.c linux-2.6.18/drivers/sbus/char/vfc_dev.c
--- linux-2.6.18-orig/drivers/sbus/char/vfc_dev.c 2006-09-21 10:15:38.000000000 +0530
+++ linux-2.6.18/drivers/sbus/char/vfc_dev.c 2006-09-27 14:46:59.000000000 +0530
@@ -678,8 +678,14 @@ static int vfc_probe(void)
if (strcmp(sdev->prom_name, "vfc") == 0) {
vfc_dev_lst[instance]=(struct vfc_dev *)
kmalloc(sizeof(struct vfc_dev), GFP_KERNEL);
- if (vfc_dev_lst[instance] == NULL)
+ if (vfc_dev_lst[instance] == NULL) {
+ int i;
+ for (i = 0; i < instance; i++) {
+ if (vfc_dev_lst[i]->regs)
+ sbus_iounmap(vfc_dev_lst[i]->regs, sizeof(struct vfc_regs));
+ }
return -ENOMEM;
+ }
ret = init_vfc_device(sdev,
vfc_dev_lst[instance],
instance);


-
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/