From patchwork Fri Apr 1 07:08:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 8721161 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E53C9F38C for ; Fri, 1 Apr 2016 07:08:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3344203B1 for ; Fri, 1 Apr 2016 07:08:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ADB59203AE for ; Fri, 1 Apr 2016 07:08:52 +0000 (UTC) Received: from localhost ([::1]:36302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1altCM-0006TL-Sy for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Apr 2016 03:08:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1altCG-0006TG-Ao for qemu-devel@nongnu.org; Fri, 01 Apr 2016 03:08:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1altCD-0005YZ-5E for qemu-devel@nongnu.org; Fri, 01 Apr 2016 03:08:44 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:60851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1altCC-0005XA-3Y for qemu-devel@nongnu.org; Fri, 01 Apr 2016 03:08:41 -0400 Received: from 172.24.1.48 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.48]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DHZ59002; Fri, 01 Apr 2016 15:08:26 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Fri, 1 Apr 2016 15:08:16 +0800 From: zhanghailiang To: Date: Fri, 1 Apr 2016 15:08:09 +0800 Message-ID: <1459494489-3532-1-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.56FE1E6C.0098, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 549588c8bae20d036e1840df6d2f3152 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: jasowang@redhat.com, zhanghailiang Subject: [Qemu-devel] [PATCH] filter-buffer: fix segfault while start 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(). Let's check the value of 's->incoming_queue' before calling qemu_net_queue_flush(). Signed-off-by: zhanghailiang --- net/filter-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/filter-buffer.c b/net/filter-buffer.c index cc6bd94..79e2ce3 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -34,7 +34,7 @@ static void filter_buffer_flush(NetFilterState *nf) { FilterBufferState *s = FILTER_BUFFER(nf); - if (!qemu_net_queue_flush(s->incoming_queue)) { + if (s->incoming_queue && !qemu_net_queue_flush(s->incoming_queue)) { /* Unable to empty the queue, purge remaining packets */ qemu_net_queue_purge(s->incoming_queue, nf->netdev); }