netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Latchesar Ionkov" <lucho@ionkov.net>
To: "Eric Van Hensbergen" <ericvh@gmail.com>
Cc: "Adrian Bunk" <bunk@stusta.de>,
	v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: net/9p/mux.c: use-after-free
Date: Wed, 25 Jul 2007 13:13:34 -0600	[thread overview]
Message-ID: <f158dc670707251213i65501f9eh6d35a8712583cd90@mail.gmail.com> (raw)
In-Reply-To: <a4e6962a0707251143ie0b0ce8s7d4a9078fed7eb26@mail.gmail.com>

Yep, it's a leak.

Thanks,
    Lucho

On 7/25/07, Eric Van Hensbergen <ericvh@gmail.com> wrote:
> On 7/22/07, Adrian Bunk <bunk@stusta.de> wrote:
> > The Coverity checker spotted the following use-after-free
> > in net/9p/mux.c:
> >
> > <--  snip  -->
> >
> > ...
> > struct p9_conn *p9_conn_create(struct p9_transport *trans, int msize,
> >                                     unsigned char *extended)
> > {
> > ...
> >         if (!m->tagpool) {
> >                 kfree(m);
> >                 return ERR_PTR(PTR_ERR(m->tagpool));
> >         }
> > ...
> >
> > <--  snip  -->
> >
>
> I've got a fix for this one:
>         if (!m->tagpool) {
>                 mtmp = ERR_PTR(PTR_ERR(m->tagpool));
>                 kfree(m);
>                 return mtmp;
>         }
>
> but I was wondering about one of the other returns further down the function:
>
> ...
>         memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
>         m->poll_task = NULL;
>         n = p9_mux_poll_start(m);
>         if (n)
>                 return ERR_PTR(n);
>
>         n = trans->poll(trans, &m->pt);
> ...
>
> lucho: doesn't that constitute a leak?  Shouldn't we be doing:
>
>         if (n) {
>                 kfree(m);
>                 return ERR_PTR(n);
>         }
>
>          -eric
>

  reply	other threads:[~2007-07-25 19:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23  1:20 net/9p/mux.c: use-after-free Adrian Bunk
2007-07-25 18:43 ` Eric Van Hensbergen
2007-07-25 19:13   ` Latchesar Ionkov [this message]
2007-07-25 19:45     ` Eric Van Hensbergen

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=f158dc670707251213i65501f9eh6d35a8712583cd90@mail.gmail.com \
    --to=lucho@ionkov.net \
    --cc=bunk@stusta.de \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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).