From patchwork Wed Mar 31 15:46:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 49163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D7EEB7CFA for ; Thu, 1 Apr 2010 03:00:08 +1100 (EST) Received: from localhost ([127.0.0.1]:44379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nx0Kb-0003Bp-0k for incoming@patchwork.ozlabs.org; Wed, 31 Mar 2010 11:59:49 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nx08v-0007P9-4Y for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:47:45 -0400 Received: from [140.186.70.92] (port=40589 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nx08s-0007Nf-02 for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:47:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nx08m-0007wz-Fq for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:47:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11268) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nx08m-0007wq-5p for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:47:36 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2VFlZ8F025357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 31 Mar 2010 11:47:35 -0400 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2VFlVHf022336; Wed, 31 Mar 2010 11:47:33 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 31 Mar 2010 17:46:59 +0200 Message-Id: <1270050419-16425-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] virtio-blk: Fix use after free in error case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org virtio_blk_req_complete frees the request, so we can't access it any more when calling bdrv_mon_event. Use the pointer that was copied earlier. Signed-off-by: Kevin Wolf Acked-by: Luiz Capitulino --- hw/virtio-blk.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 9915840..01d77b8 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -65,7 +65,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, VirtIOBlock *s = req->dev; if (action == BLOCK_ERR_IGNORE) { - bdrv_mon_event(req->dev->bs, BDRV_ACTION_IGNORE, is_read); + bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read); return 0; } @@ -73,11 +73,11 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, || action == BLOCK_ERR_STOP_ANY) { req->next = s->rq; s->rq = req; - bdrv_mon_event(req->dev->bs, BDRV_ACTION_STOP, is_read); + bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read); vm_stop(0); } else { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); - bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read); + bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read); } return 1;