From ffb9c6fcec12d551ce403f5ef17539fbf681e369 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Romieu?= Date: Thu, 30 Sep 2004 15:40:35 -0400 Subject: [PATCH] [PATCH] sata_nv: wrong failure path and leak - 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 --- drivers/scsi/sata_nv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 40666718840e9..cb46e2f993682 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c @@ -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); -- 2.53.0