qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] filter-buffer: fix segfault when starting qemu with status=off property
Date: Tue, 5 Apr 2016 16:32:25 +0800	[thread overview]
Message-ID: <57037819.9030208@redhat.com> (raw)
In-Reply-To: <1459827835-7524-1-git-send-email-zhang.zhanghailiang@huawei.com>



On 04/05/2016 11:43 AM, zhanghailiang wrote:
> After commit 338d3f, we support 'status' property for filter object.
> The segfault can be triggered by starting qemu with 'status=off' property
> for filter, when the s->incoming_queue is NULL, we reference it directly
> in qemu_net_queue_flush() which was called in status_changed() callback
> function.
>
> We shouldn't trigger status_changed() before the filter was initialized,
> We can check the value of 'nf->netdev' to confirm if the filter is
> initialized or not, so let's check its value before calling
> status_changed().
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
> v2:
>  - fix the segfault by skipping calling status_changed() if the filter
>    is not initialized. (Jason Wang's suggestion)
> ---
>  net/filter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/filter.c b/net/filter.c
> index 1c4fc5a..8ac79f3 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -164,7 +164,7 @@ static void netfilter_set_status(Object *obj, const char *str, Error **errp)
>          return;
>      }
>      nf->on = !nf->on;
> -    if (nfc->status_changed) {
> +    if (nf->netdev && nfc->status_changed) {
>          nfc->status_changed(nf, errp);
>      }
>  }

Applied to -net.

Thanks

      reply	other threads:[~2016-04-05  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05  3:43 [Qemu-devel] [PATCH v2] filter-buffer: fix segfault when starting qemu with status=off property zhanghailiang
2016-04-05  8:32 ` Jason Wang [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=57037819.9030208@redhat.com \
    --to=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhang.zhanghailiang@huawei.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;
as well as URLs for NNTP newsgroup(s).