Skip to content

Commit

Permalink
mtd: maps: Eliminate use after free
Browse files Browse the repository at this point in the history
Moved the debugging message before the call to map_destroy, which frees its
argument.  The message is also slightly changed to reflect its new
position.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E,E2;
@@

del_mtd_device(E)
...
(
  E = E2
|
* E
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Julia Lawall authored and David Woodhouse committed May 10, 2010
1 parent c4e7737 commit 258006d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/maps/pcmciamtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ static void pcmciamtd_detach(struct pcmcia_device *link)

if(dev->mtd_info) {
del_mtd_device(dev->mtd_info);
info("mtd%d: Removing", dev->mtd_info->index);
map_destroy(dev->mtd_info);
info("mtd%d: Removed", dev->mtd_info->index);
}

pcmciamtd_release(link);
Expand Down

0 comments on commit 258006d

Please sign in to comment.