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 From: Luiz Capitulino 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> Subject: [Qemu-devel] [PATCH 19/21] virtio-blk: Fix use after free in error case List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: Kevin Wolf , qemu-devel@nongnu.org, Luiz Capitulino 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; -- 1.7.0.4.297.g6555b1