From patchwork Mon Apr 5 20:34:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 49451 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 CDB6FB7D1F for ; Tue, 6 Apr 2010 07:30:57 +1000 (EST) Received: from localhost ([127.0.0.1]:55352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NytUa-00017I-D5 for incoming@patchwork.ozlabs.org; Mon, 05 Apr 2010 17:05:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nyt3Z-0002I0-2l for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:38:01 -0400 Received: from [140.186.70.92] (port=49501 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nyt3X-0001Wi-Gr for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:38:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nyt0c-0001fX-8A for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:35:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28713) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nyt0b-0001fM-Vt for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:58 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYuhf002993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Apr 2010 16:34:57 -0400 Received: from localhost (vpn-8-191.rdu.redhat.com [10.11.8.191]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYtlo001665; Mon, 5 Apr 2010 16:34:56 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 5 Apr 2010 17:34:00 -0300 Message-Id: <1270499642-31543-20-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> References: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf , qemu-devel@nongnu.org, Luiz Capitulino Subject: [Qemu-devel] [PATCH 19/21] 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 From: Kevin Wolf 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 Signed-off-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;