aoe: fix use after free in aoedev_by_aoeaddr()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 18 Dec 2012 00:04:21 +0000 (16:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 18 Dec 2012 01:15:26 +0000 (17:15 -0800)
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>
drivers/block/aoe/aoedev.c

index e66ccbf41a50b3013012ec7fd64c64e13ac8c051..98f2965778b9ce18a4a58aaf91544d5b35a3d134 100644 (file)
@@ -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;