From patchwork Mon Nov 11 16:06:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 290368 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 8A0BC2C00AC for ; Tue, 12 Nov 2013 03:04:03 +1100 (EST) Received: from localhost ([::1]:37944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfty4-00062g-Rg for incoming@patchwork.ozlabs.org; Mon, 11 Nov 2013 11:04:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vftxa-0005yc-0B for qemu-devel@nongnu.org; Mon, 11 Nov 2013 11:03:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VftxV-00050j-0H for qemu-devel@nongnu.org; Mon, 11 Nov 2013 11:03:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VftxU-00050d-PU; Mon, 11 Nov 2013 11:03:24 -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 rABG3LOY015906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Nov 2013 11:03:21 -0500 Received: from redhat.com (vpn1-4-246.ams2.redhat.com [10.36.4.246]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id rABG3Jkg021885; Mon, 11 Nov 2013 11:03:19 -0500 Date: Mon, 11 Nov 2013 18:06:19 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1384159176-31662-3-git-send-email-mst@redhat.com> References: <1384159176-31662-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1384159176-31662-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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, Anthony Liguori Subject: [Qemu-devel] [PULL 2/6] 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 From: Jason Wang 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 Signed-off-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); } }