[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2] filter-buffer: fix segfault when starting qemu w

From: zhanghailiang
Subject: [Qemu-devel] [PATCH v2] filter-buffer: fix segfault when starting qemu with status=off property
Date: Tue, 5 Apr 2016 11:43:55 +0800

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

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

Signed-off-by: zhanghailiang <address@hidden>
 - 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)
     nf->on = !nf->on;
-    if (nfc->status_changed) {
+    if (nf->netdev && nfc->status_changed) {
         nfc->status_changed(nf, errp);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]