Skip to content

Commit

Permalink
aoe: fix use after free in aoedev_by_aoeaddr()
Browse files Browse the repository at this point in the history
We should return NULL on failure instead of returning a freed pointer.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ed Cashin <ecashin@coraid.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Dan Carpenter authored and Linus Torvalds committed Dec 18, 2012
1 parent 2b37c7d commit 31279b1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/block/aoe/aoedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
d->targets = kcalloc(NTARGETS, sizeof(*d->targets), GFP_ATOMIC);
if (!d->targets) {
kfree(d);
d = NULL;
goto out;
}
d->ntargets = NTARGETS;
Expand Down

0 comments on commit 31279b1

Please sign in to comment.