Skip to contentSkip to conversation

ioremap balanced with iounmap for drivers/scsi/seagate.c

PATCH In review [email protected] 1 participant 1 message Oct 10, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 18/36 ioremap balanced with iounmap for drivers/scsi/seagate.c

From: Amol Lad <[email protected]>

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

---

 drivers/scsi/seagate.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)
drivers/scsi/seagate.c renamed from drivers/scsi/seagate.c~ioremap-balanced-with-iounmap-drivers-scsi-seagatec +12 -1
diff -puN drivers/scsi/seagate.c~ioremap-balanced-with-iounmap-drivers-scsi-seagatec drivers/scsi/seagate.c
@@ -494,12 +494,19 @@ int __init seagate_st0x_detect (struct s
 	 *	if we lose our first interrupt.
 	 */
 	instance = scsi_register (tpnt, 0);
-	if (instance == NULL)
+	if (instance == NULL) {
+		iounmap(st0x_cr_sr);
+		iounmap(st0x_dr);
+		st0x_cr_sr = st0x_dr = NULL;
 		return 0;
+	}
 
 	hostno = instance->host_no;
 	if (request_irq (irq, do_seagate_reconnect_intr, IRQF_DISABLED, (controller_type == SEAGATE) ? "seagate" : "tmc-8xx", instance)) {
 		printk(KERN_ERR "scsi%d : unable to allocate IRQ%d\n", hostno, irq);
+		iounmap(st0x_cr_sr);
+		iounmap(st0x_dr);
+		st0x_cr_sr = st0x_dr = NULL;
 		return 0;
 	}
 	instance->irq = irq;
@@ -1646,6 +1653,10 @@ static int seagate_st0x_release(struct S
 {
 	if (shost->irq)
 		free_irq(shost->irq, shost);
+	if (st0x_cr_sr)
+		iounmap(st0x_cr_sr);
+	if (st0x_dr)
+		iounmap(st0x_dr);
 	release_region(shost->io_port, shost->n_io_port);
 	return 0;
 }

_