From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a18b2-0000HV-RN for qemu-devel@nongnu.org; Tue, 24 Nov 2015 03:05:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a18az-00054J-KN for qemu-devel@nongnu.org; Tue, 24 Nov 2015 03:05:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a18az-00053w-E2 for qemu-devel@nongnu.org; Tue, 24 Nov 2015 03:05:01 -0500 From: Stefan Hajnoczi Date: Tue, 24 Nov 2015 16:04:42 +0800 Message-Id: <1448352282-27750-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1448352282-27750-1-git-send-email-stefanha@redhat.com> References: <1448352282-27750-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL for-2.5 2/2] virtio-blk: Move resetting of req->mr_next to virtio_blk_handle_rw_error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Fam Zheng , Stefan Hajnoczi From: Fam Zheng "werror=report" would free the req in virtio_blk_handle_rw_error, we mustn't write to it in that case. Reported-by: Paolo Bonzini Signed-off-by: Fam Zheng Message-id: 1448239280-15025-1-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 848f3fe..756ae5c 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -72,6 +72,9 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, VirtIOBlock *s = req->dev; if (action == BLOCK_ERROR_ACTION_STOP) { + /* Break the link as the next request is going to be parsed from the + * ring again. Otherwise we may end up doing a double completion! */ + req->mr_next = NULL; req->next = s->rq; s->rq = req; } else if (action == BLOCK_ERROR_ACTION_REPORT) { @@ -112,10 +115,6 @@ static void virtio_blk_rw_complete(void *opaque, int ret) * happen on the other side of the migration). */ if (virtio_blk_handle_rw_error(req, -ret, is_read)) { - /* Break the link in case the next request is added to the - * restart queue and is going to be parsed from the ring again. - */ - req->mr_next = NULL; continue; } } -- 2.5.0