hw/xen_disk: ioreq not finished on error

Bug fix: routines 'ioreq_runio_qemu_sync' and 'ioreq_runio_qemu_aio'
won't call 'ioreq_unmap' or 'ioreq_finish' on errors, leaving ioreq in
the blkdev->inflight list and a leak.

Signed-off-by: Feiran Zheng <famcool@gmail.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Feiran Zheng 2011-03-29 09:00:15 +08:00 committed by Kevin Wolf
parent 3b8e6a2db1
commit f6ec953ca3

View File

@ -310,7 +310,7 @@ static int ioreq_runio_qemu_sync(struct ioreq *ioreq)
off_t pos; off_t pos;
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1) if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
goto err; goto err_no_map;
if (ioreq->presync) if (ioreq->presync)
bdrv_flush(blkdev->bs); bdrv_flush(blkdev->bs);
@ -364,6 +364,9 @@ static int ioreq_runio_qemu_sync(struct ioreq *ioreq)
return 0; return 0;
err: err:
ioreq_unmap(ioreq);
err_no_map:
ioreq_finish(ioreq);
ioreq->status = BLKIF_RSP_ERROR; ioreq->status = BLKIF_RSP_ERROR;
return -1; return -1;
} }
@ -393,7 +396,7 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
struct XenBlkDev *blkdev = ioreq->blkdev; struct XenBlkDev *blkdev = ioreq->blkdev;
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1) if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
goto err; goto err_no_map;
ioreq->aio_inflight++; ioreq->aio_inflight++;
if (ioreq->presync) if (ioreq->presync)
@ -427,6 +430,9 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
return 0; return 0;
err: err:
ioreq_unmap(ioreq);
err_no_map:
ioreq_finish(ioreq);
ioreq->status = BLKIF_RSP_ERROR; ioreq->status = BLKIF_RSP_ERROR;
return -1; return -1;
} }