[patch 18/45] ioremap balanced with iounmap for drivers/scsi/seagate.c

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

 



From: Amol Lad <amol@xxxxxxxxxxxxxxxxxxx>

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

Signed-off-by: Amol Lad <amol@xxxxxxxxxxxxxxxxxxx>
Cc: James Bottomley <James.Bottomley@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/scsi/seagate.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)

diff -puN drivers/scsi/seagate.c~ioremap-balanced-with-iounmap-drivers-scsi-seagatec drivers/scsi/seagate.c
--- a/drivers/scsi/seagate.c~ioremap-balanced-with-iounmap-drivers-scsi-seagatec
+++ a/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;
 }
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux