From patchwork Wed Apr 6 02:38:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 606825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qfqjJ0Rlqz9t4F for ; Wed, 6 Apr 2016 12:41:08 +1000 (AEST) Received: from localhost ([::1]:40332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1andP0-00061G-At for incoming@patchwork.ozlabs.org; Tue, 05 Apr 2016 22:41:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1andMH-0001AD-Ph for qemu-devel@nongnu.org; Tue, 05 Apr 2016 22:38:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1andME-0002nK-Jg for qemu-devel@nongnu.org; Tue, 05 Apr 2016 22:38:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1andME-0002n4-Db for qemu-devel@nongnu.org; Tue, 05 Apr 2016 22:38:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E801C0AAB23; Wed, 6 Apr 2016 02:38:14 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-7-238.pek2.redhat.com [10.72.7.238]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u362c1Af016115; Tue, 5 Apr 2016 22:38:12 -0400 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Wed, 6 Apr 2016 10:38:00 +0800 Message-Id: <1459910280-5101-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1459910280-5101-1-git-send-email-jasowang@redhat.com> References: <1459910280-5101-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Jason Wang , zhanghailiang Subject: [Qemu-devel] [PULL 5/5] filter-buffer: fix segfault when starting qemu with status=off property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: zhanghailiang 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 Signed-off-by: Jason Wang --- 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); } }