diff mbox

drivers/mtd/maps/ts5500_flash.c: avoid calling map_destroy on NULL

Message ID 1296666816-21610-1-git-send-email-julia@diku.dk
State Accepted
Commit 3ee7451a023dd197fcfc1ba46dcce6d8ec5e1b78
Headers show

Commit Message

Julia Lawall Feb. 2, 2011, 5:13 p.m. UTC
map_destroy dereferences its argument.  The call is furthermore only
reachable when this argument is NULL.  Thus the call is dropped.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
@@

*if (x == NULL)
{ ...
* map_destroy(x);
  ...
  return ...;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/mtd/maps/ts5500_flash.c |    1 -
 1 file changed, 1 deletion(-)

Comments

Artem Bityutskiy Feb. 6, 2011, 3:08 p.m. UTC | #1
On Wed, 2011-02-02 at 18:13 +0100, Julia Lawall wrote:
> map_destroy dereferences its argument.  The call is furthermore only
> reachable when this argument is NULL.  Thus the call is dropped.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)

Pushed to l2-mtd-2.6.git, thanks!
diff mbox

Patch

diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c
index e2147bf..e02dfa9 100644
--- a/drivers/mtd/maps/ts5500_flash.c
+++ b/drivers/mtd/maps/ts5500_flash.c
@@ -94,7 +94,6 @@  static int __init init_ts5500_map(void)
 	return 0;
 
 err1:
-	map_destroy(mymtd);
 	iounmap(ts5500_map.virt);
 err2:
 	return rc;