Skip to contentSkip to conversation

drivers/char/serial.c unchecked ioremap() calls

PATCH In review Andrey Panin 3 participants 4 messages Feb 23, 2001 – Feb 26, 2001 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/char/serial.c unchecked ioremap() calls

Hi all,

16x50 serial driver doesn't check ioremap() return value. Atached patch should fix this it.

Best regards.

Signature · 2 lines
Andrey Panin            | Embedded systems software engineer
[email protected]        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
drivers/char/serial.c +6 -3
diff -ur linux.vanilla/drivers/char/serial.c linux/drivers/char/serial.c
@@ -3876,7 +3876,8 @@
 		return 0;
 	}
 	req->io_type = SERIAL_IO_MEM;
-	req->iomem_base = ioremap(port, board->uart_offset);
+	if ((req->iomem_base = ioremap(port, board->uart_offset)) == NULL)
+		return 1;
 	req->iomem_reg_shift = board->reg_shift;
 	req->port = 0;
 	return 0;
@@ -4010,7 +4011,8 @@
 				      data | pci_config);
 	
 	/* enable/disable interrupts */
-	p = ioremap(pci_resource_start(dev, 0), 0x80);
+	if ((p = ioremap(pci_resource_start(dev, 0), 0x80)) == NULL)
+		return 1;
 	writel(enable ? irq_config : 0x00, (unsigned long)p + 0x4c);
 	iounmap(p);
 
@@ -4053,7 +4055,8 @@
 
        if (!enable) return 0;
 
-       p = ioremap(pci_resource_start(dev, 0), 0x80);
+       if ((p = ioremap(pci_resource_start(dev, 0), 0x80)) == NULL)
+		return 1;
 
        switch (dev->device & 0xfff8) {
                case PCI_DEVICE_ID_SIIG_1S_10x:         /* 1S */
#1 lore raw

Em Fri, Feb 23, 2001 at 10:53:59AM +0300, Andrey Panin escreveu:

Quoted 5 lines

Hi all,

16x50 serial driver doesn't check ioremap() return value. Atached patch should fix this it.

humm, have not checked, but it seems as if you don't release the previous successful mappings on failure. Wipe out this message if I was too quick to answer and this is not true. 8)

- Arnaldo

#2 lore raw
In reply to Andrey Panin
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Fri, Feb 23, 2001 at 10:53:59AM +0300, Andrey Panin escreveu:

Quoted 5 lines

Hi all,

16x50 serial driver doesn't check ioremap() return value. Atached patch should fix this it.

humm, have not checked, but it seems as if you don't release the previous successful mappings on failure. Wipe out this message if I was too quick to answer and this is not true. 8)

Also, the proper return from a failed ioremap is -ENOMEM, so I think Andrey's serial.c patch should modify some functions to return a failure code...

Jeff

Signature · 3 lines
Jeff Garzik       | "You see, in this world there's two kinds of
Building 1024     |  people, my friend: Those with loaded guns
MandrakeSoft      |  and those who dig. You dig."  --Blondie
#3 lore raw
In reply to Andrey Panin
Quoted 9 lines · Jeff Garzik
Quoted 8 lines · Arnaldo Carvalho de Melo

Em Fri, Feb 23, 2001 at 10:53:59AM +0300, Andrey Panin escreveu:

Quoted 5 lines

Hi all,

16x50 serial driver doesn't check ioremap() return value. Atached patch should fix this it.

Quoted 8 lines
Quoted 3 lines

humm, have not checked, but it seems as if you don't release the previous successful mappings on failure. Wipe out this message if I was too quick to answer and this is not true. 8)

Also, the proper return from a failed ioremap is -ENOMEM, so I think Andrey's serial.c patch should modify some functions to return a failure code...

All these ioremap() failures are not fatal,
just fail to init one PCI/ISAPNP device or one serial port. IMHO a warning message will be enough for them :)

Signature · 2 lines
Andrey Panin            | Embedded systems software engineer
[email protected]        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc