[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1326362117-29371-7-git-send-email-Julia.Lawall@lip6.fr>
Date: Thu, 12 Jan 2012 10:55:09 +0100
From: Julia Lawall <Julia.Lawall@...6.fr>
To: "James E.J. Bottomley" <JBottomley@...allels.com>
Cc: kernel-janitors@...r.kernel.org, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 7/15] drivers/scsi/mvsas/mv_init.c: add missing iounmap
From: Julia Lawall <Julia.Lawall@...6.fr>
Add missing iounmap in error handling code, in a case where the function
already preforms iounmap on some other execution path.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e;
statement S,S1;
int ret;
@@
e = \(ioremap\|ioremap_nocache\)(...)
... when != iounmap(e)
if (<+...e...+>) S
... when any
when != iounmap(e)
*if (...)
{ ... when != iounmap(e)
return ...; }
... when any
iounmap(e);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@...6.fr>
---
This changes the semantics at the point of the first change, as it
introduces the setting of mvi->regs_ex to NULL. I do not know if this is
correct.
It also assumes that if mvi->regs_ex is non-null, then bar_ex != -1.
This seems to be already assumed in the second block of error handling code.
drivers/scsi/mvsas/mv_init.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 6f58919..adfd11f 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -350,7 +350,7 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
res_start = pci_resource_start(pdev, bar);
res_len = pci_resource_len(pdev, bar);
if (!res_start || !res_len)
- goto err_out;
+ goto err_unmap;
res_flag = pci_resource_flags(pdev, bar);
if (res_flag & IORESOURCE_CACHEABLE)
@@ -358,14 +358,15 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
else
mvi->regs = ioremap_nocache(res_start, res_len);
- if (!mvi->regs) {
- if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))
- iounmap(mvi->regs_ex);
- mvi->regs_ex = NULL;
- goto err_out;
- }
+ if (!mvi->regs)
+ goto err_unmap;
return 0;
+err_unmap:
+ if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))
+ iounmap(mvi->regs_ex);
+ mvi->regs_ex = NULL;
+
err_out:
return -1;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists