Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: "Han, Weidong" <weidong.han@intel.com>
Cc: "'Avi Kivity'" <avi@redhat.com>,
	"'kvm@vger.kernel.org'" <kvm@vger.kernel.org>
Subject: Re: [PATCH 2/4] [v2] kvm: qemu: Fix leak of ioperm data
Date: Wed, 10 Dec 2008 13:25:46 +0000	[thread overview]
Message-ID: <1228915546.5384.47.camel@blaa> (raw)
In-Reply-To: <715D42877B251141A38726ABF5CABF2C018BF9AD47@pdsmsx503.ccr.corp.intel.com>

On Wed, 2008-12-10 at 21:22 +0800, Han, Weidong wrote:
> 
> +void kvm_remove_ioperm_data(unsigned long start_port, unsigned long num)
> +{
> +    struct ioperm_data *data;
> +
> +    data = LIST_FIRST(&ioperm_head);
> +    while (data) {
> +        if (data->start_port == start_port && data->num == num) {
> +            LIST_REMOVE(data, entries);
> +            qemu_free(data);
> +        }
> +
> +        data = LIST_NEXT(data, entries);
> +    }
> +}

Repeating what I said last time:

     You've a "use after free bug" here; you free the structure and
     LIST_NEXT de-references the pointer to it in order to obtain the
     pointer to the next structure.

What you need is:

{
    struct ioperm_data *data;

    data = LIST_FIRST(&ioperm_head);
    while (data) {
        struct ioperm_data *next = LIST_NEXT(data, entries);

        if (data->start_port == start_port && data->num == num) {
            LIST_REMOVE(data, entries);
            qemu_free(data);
        }

        data = next;
    }
}

Cheers,
Mark.


  reply	other threads:[~2008-12-10 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10 13:22 [PATCH 2/4] [v2] kvm: qemu: Fix leak of ioperm data Han, Weidong
2008-12-10 13:25 ` Mark McLoughlin [this message]
2008-12-10 13:33   ` Han, Weidong
2008-12-10 13:42   ` Han, Weidong

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=1228915546.5384.47.camel@blaa \
    --to=markmc@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=weidong.han@intel.com \
    /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