linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ed Cashin <ecashin@coraid.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [patch] aoe: use after free in aoedev_by_aoeaddr()
Date: Mon, 10 Dec 2012 11:59:15 +0300	[thread overview]
Message-ID: <20121210085915.GP6568@mwanda> (raw)
In-Reply-To: <A578B7C2-D1FA-4F14-999F-E4CAA4816BB3@coraid.com>

On Fri, Dec 07, 2012 at 07:20:10AM -0600, Ed Cashin wrote:
> 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.  :/

It's one of the checks which is only enabled with the --spammy
option.

regards,
dan carpenter


      reply	other threads:[~2012-12-10  8:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  6:19 [patch] aoe: use after free in aoedev_by_aoeaddr() Dan Carpenter
2012-12-07 13:20 ` Ed Cashin
2012-12-10  8:59   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121210085915.GP6568@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=ecashin@coraid.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).