[PATCH] WAN: ioremap() failure checks in drivers
authorKrzysztof Halasa <khc@pm.waw.pl>
Thu, 22 Jun 2006 20:29:28 +0000 (22:29 +0200)
committerJeff Garzik <jeff@garzik.org>
Fri, 23 Jun 2006 03:32:03 +0000 (23:32 -0400)
Eric Sesterhenn found that pci200syn initialization lacks return
statement in ioremap() error path (coverity bug id #195). It looks
like more WAN drivers have problems with ioremap().

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/wan/c101.c
drivers/net/wan/n2.c
drivers/net/wan/pci200syn.c
drivers/net/wan/wanxl.c

index 43d854ace2333a6f52341ba31b3c5f002700d0dd..b60ef02db7b06b6a8868fce2e4ec44fb304b6eb9 100644 (file)
@@ -326,21 +326,21 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
        if (request_irq(irq, sca_intr, 0, devname, card)) {
                printk(KERN_ERR "c101: could not allocate IRQ\n");
                c101_destroy_card(card);
-               return(-EBUSY);
+               return -EBUSY;
        }
        card->irq = irq;
 
        if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) {
                printk(KERN_ERR "c101: could not request RAM window\n");
                c101_destroy_card(card);
-               return(-EBUSY);
+               return -EBUSY;
        }
        card->phy_winbase = winbase;
        card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE);
        if (!card->win0base) {
                printk(KERN_ERR "c101: could not map I/O address\n");
                c101_destroy_card(card);
-               return -EBUSY;
+               return -EFAULT;
        }
 
        card->tx_ring_buffers = TX_RING_BUFFERS;
index cd32751b64eb6e6f6e8355a54a21e3cf751b15cc..b7d88db89a5c7918e5a827aeb6465cab7b5411a7 100644 (file)
@@ -387,6 +387,11 @@ static int __init n2_run(unsigned long io, unsigned long irq,
        }
        card->phy_winbase = winbase;
        card->winbase = ioremap(winbase, USE_WINDOWSIZE);
+       if (!card->winbase) {
+               printk(KERN_ERR "n2: ioremap() failed\n");
+               n2_destroy_card(card);
+               return -EFAULT;
+       }
 
        outb(0, io + N2_PCR);
        outb(winbase >> 12, io + N2_BAR);
index f485a97844ccf3f06dc4e5b6b76053e5245d7ad9..670e8bd2245c7fef651df170cf889fc8e33c4f51 100644 (file)
@@ -354,6 +354,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
            card->rambase == NULL) {
                printk(KERN_ERR "pci200syn: ioremap() failed\n");
                pci200_pci_remove_one(pdev);
+               return -EFAULT;
        }
 
        /* Reset PLX */
index 29a756dd979b4e72e1126f9f65d96c6af856e4a4..437e0e938e38ba7c0239d4a7e9c6b732faa742fc 100644 (file)
@@ -634,7 +634,13 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
 
        /* set up PLX mapping */
        plx_phy = pci_resource_start(pdev, 0);
+
        card->plx = ioremap_nocache(plx_phy, 0x70);
+       if (!card->plx) {
+               printk(KERN_ERR "wanxl: ioremap() failed\n");
+               wanxl_pci_remove_one(pdev);
+               return -EFAULT;
+       }
 
 #if RESET_WHILE_LOADING
        wanxl_reset(card);
@@ -700,6 +706,12 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
        }
 
        mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware));
+       if (!mem) {
+               printk(KERN_ERR "wanxl: ioremap() failed\n");
+               wanxl_pci_remove_one(pdev);
+               return -EFAULT;
+       }
+
        for (i = 0; i < sizeof(firmware); i += 4)
                writel(htonl(*(u32*)(firmware + i)), mem + PDM_OFFSET + i);