LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: "Michael S. Tsirkin" <mst@mellanox.co.il>
Cc: Roland Dreier <rolandd@cisco.com>,
	mshefty@ichips.intel.com, halr@voltaire.com,
	openib-general@openib.org, linux-kernel@vger.kernel.org
Subject: drivers/infiniband/ulp/ipoib/ipoib_main.c: use-after-free
Date: Mon, 19 Mar 2007 10:23:10 +0100	[thread overview]
Message-ID: <20070319092310.GJ752@stusta.de> (raw)

The Coverity checker spotted the following code introduced by
commit 839fcaba355abaffb7b44f0f4504093acb0b11cf:

<--  snip  -->

...
static void path_rec_completion(int status,
                                struct ib_sa_path_rec *pathrec,
                                void *path_ptr)
{
...
                list_for_each_entry(neigh, &path->neigh_list, list) {
                        kref_get(&path->ah->ref);
                        neigh->ah = path->ah;
                        memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
                               sizeof(union ib_gid));

                        if (ipoib_cm_enabled(dev, neigh->neighbour)) {
                                if (!ipoib_cm_get(neigh))
                                        ipoib_cm_set(neigh, ipoib_cm_create_tx(dev,
                                                                               path,
                                                                               neigh));
                                if (!ipoib_cm_get(neigh)) {
                                        list_del(&neigh->list);
                                        if (neigh->ah)
                                                ipoib_put_ah(neigh->ah);
                                        ipoib_neigh_free(dev, neigh);
                                        continue;
                                }
                        }

                        while ((skb = __skb_dequeue(&neigh->queue)))
                                __skb_queue_tail(&skqueue, skb);
                }
...

<--  snip  -->

Notice that before the continue "neigh" gets freed, but the 
list_for_each_entry() for() loop uses it.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


             reply	other threads:[~2007-03-19  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-19  9:23 Adrian Bunk [this message]
2007-03-19  9:46 ` [ofa-general] " Michael S. Tsirkin
2007-03-22 18:04   ` Roland Dreier

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=20070319092310.GJ752@stusta.de \
    --to=bunk@stusta.de \
    --cc=halr@voltaire.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mshefty@ichips.intel.com \
    --cc=mst@mellanox.co.il \
    --cc=openib-general@openib.org \
    --cc=rolandd@cisco.com \
    --subject='Re: drivers/infiniband/ulp/ipoib/ipoib_main.c: use-after-free' \
    /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

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).