Skip to contentSkip to conversation

drivers/net/sunhme.c, unbalanced and unchecked ioremap()

PATCH In review Andrey Panin 2 participants 2 messages Feb 22, 2001 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/sunhme.c, unbalanced and unchecked ioremap()

Hi all,

I found that sunhme.c doesn't check ioremap() return value and doesn't call iounmap() on module unload. Attached patch (for 2.4.1-ac20) should fix it, compiles clearly, but untested (I have no such hardware).

Best regards.

Signature · 2 lines
Andrey Panin            | Embedded systems software engineer
[email protected]        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
drivers/net/sunhme.c +5 -1
diff -ur linux.vanilla/drivers/net/sunhme.c linux/drivers/net/sunhme.c
@@ -2856,7 +2856,10 @@
 		printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
 		return -ENODEV;
 	}
-	hpreg_base = (unsigned long) ioremap(hpreg_base, 0x8000);
+	if ((hpreg_base = (unsigned long) ioremap(hpreg_base, 0x8000)) == 0) {
+		printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
+		return -ENODEV;
+	}
 
 	for (i = 0; i < 6; i++) {
 		if (macaddr[i] != 0)
@@ -3071,6 +3074,7 @@
 					    PAGE_SIZE,
 					    hp->happy_block,
 					    hp->hblock_dvma);
+			iounmap((void *)hp->gregs);
 		}
 #endif
 		unregister_netdev(hp->dev);
#1 lore raw
Quoted 3 lines · Andrey Panin

I found that sunhme.c doesn't check ioremap() return value and doesn't call iounmap() on module unload. Attached patch (for 2.4.1-ac20) should fix it, compiles clearly, but untested (I have no such hardware).

Thanks I've applied this patch.

Later,
David S. Miller
[email protected]