lkml.org 
[lkml]   [2012]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [patch] aoe: use after free in aoedev_by_aoeaddr()
On Dec 7, 2012, at 1:19 AM, Dan Carpenter wrote:

> We should return NULL on failure instead of returning a freed pointer.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
> index e66ccbf..98f2965 100644
> --- a/drivers/block/aoe/aoedev.c
> +++ b/drivers/block/aoe/aoedev.c
> @@ -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;


That looks good, thanks.

If smatch found that, then I have to figure out what I'm doing wrong, because
I ran sparse and smatch on the latest patch series until they were clean. :/

--
Ed Cashin
ecashin@coraid.com




\
 
 \ /
  Last update: 2012-12-07 15:01    [W:0.037 / U:1.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site