Received: from eggs.gnu.org ([2001:4830:134:3::10]:60011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNesr-0004UP-JO for qemu-devel@nongnu.org; Tue, 17 Feb 2015 04:56:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNeso-0003jv-De for qemu-devel@nongnu.org; Tue, 17 Feb 2015 04:56:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNeso-0003jn-6W for qemu-devel@nongnu.org; Tue, 17 Feb 2015 04:55:58 -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 t1H9tvsh013632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 17 Feb 2015 04:55:57 -0500 From: Fam Zheng Date: Tue, 17 Feb 2015 17:55:53 +0800 Message-Id: <1424166953-2515-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2] virtio-blk: Check return value of blk_aio_ioctl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi Since commit 1dc936aa84 (virtio-blk: Use blk_aio_ioctl) we silently lose the request if blk_aio_ioctl returns NULL (not implemented). Fix it by directly returning VIRTIO_BLK_S_UNSUPP as we used to do. Signed-off-by: Fam Zheng --- v2: Fix the leak of ioctl_req. (Kevin) --- hw/block/virtio-blk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 1a8a176..91aceaa 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -197,6 +197,7 @@ static int virtio_blk_handle_scsi_req(VirtIOBlockReq *req) VirtIODevice *vdev = VIRTIO_DEVICE(req->dev); VirtQueueElement *elem = &req->elem; VirtIOBlock *blk = req->dev; + BlockAIOCB *acb; #ifdef __linux__ int i; @@ -278,8 +279,13 @@ static int virtio_blk_handle_scsi_req(VirtIOBlockReq *req) ioctl_req->hdr.sbp = elem->in_sg[elem->in_num - 3].iov_base; ioctl_req->hdr.mx_sb_len = elem->in_sg[elem->in_num - 3].iov_len; - blk_aio_ioctl(blk->blk, SG_IO, &ioctl_req->hdr, - virtio_blk_ioctl_complete, ioctl_req); + acb = blk_aio_ioctl(blk->blk, SG_IO, &ioctl_req->hdr, + virtio_blk_ioctl_complete, ioctl_req); + if (!acb) { + g_free(ioctl_req); + status = VIRTIO_BLK_S_UNSUPP; + goto fail; + } return -EINPROGRESS; #else abort(); -- 2.1.0