]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sata_nv: wrong failure path and leak
authorFrançois Romieu <romieu@fr.zoreil.com>
Thu, 30 Sep 2004 19:40:35 +0000 (15:40 -0400)
committerJeff Garzik <jgarzik@pobox.com>
Thu, 30 Sep 2004 19:40:35 +0000 (15:40 -0400)
- wrong branching: the driver does not want to iounmap() an address that it
  has just failed to set;
- return a sensible error status code instead of a success code;
- leak plugged: host was never freed if a late error heppened.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
drivers/scsi/sata_nv.c

index 40666718840e97a5ebea4a914b23d40f4efd7840..cb46e2f99368229f987597983e0b2e63063ac9ae 100644 (file)
@@ -354,8 +354,10 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
                probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
                                pci_resource_len(pdev, 5));
-               if (probe_ent->mmio_base == NULL)
-                       goto err_out_iounmap;
+               if (probe_ent->mmio_base == NULL) {
+                       rc = -EIO;
+                       goto err_out_free_host;
+               }
 
                base = (unsigned long)probe_ent->mmio_base;
 
@@ -388,7 +390,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 err_out_iounmap:
        if (host->host_desc->host_flags & NV_HOST_FLAGS_SCR_MMIO)
                iounmap(probe_ent->mmio_base);
-
+err_out_free_host:
+       kfree(host);
 err_out_free_ent:
        kfree(probe_ent);