From patchwork Wed Nov 6 08:58:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 288800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 30E0E2C00C3 for ; Wed, 6 Nov 2013 19:59:08 +1100 (EST) Received: from localhost ([::1]:60334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vdyx6-0006Am-3I for incoming@patchwork.ozlabs.org; Wed, 06 Nov 2013 03:59:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vdywm-0006AT-PV for qemu-devel@nongnu.org; Wed, 06 Nov 2013 03:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vdywg-0004Vi-Jx for qemu-devel@nongnu.org; Wed, 06 Nov 2013 03:58:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vdywg-0004VS-Be; Wed, 06 Nov 2013 03:58:38 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA68wS8f016821 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Nov 2013 03:58:28 -0500 Received: from jason-ThinkPad-T430s.nay.redhat.com (dhcp-66-71-71.eng.nay.redhat.com [10.66.71.71] (may be forged)) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA68wLn9025441; Wed, 6 Nov 2013 03:58:24 -0500 From: Jason Wang To: aliguori@amazon.com, qemu-devel@nongnu.org, mst@redhat.com Date: Wed, 6 Nov 2013 16:58:08 +0800 Message-Id: <1383728288-28469-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH] virtio-net: only delete bh that existed 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 We delete without check whether it existed during exit. This will lead NULL pointer deference since it was created conditionally depends on guest driver status and features. So add a check of existence before trying to delete it. Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 22dbd05..ae51d96 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1601,7 +1601,7 @@ static int virtio_net_device_exit(DeviceState *qdev) if (q->tx_timer) { timer_del(q->tx_timer); timer_free(q->tx_timer); - } else { + } else if (q->tx_bh) { qemu_bh_delete(q->tx_bh); } }