Patchwork [V2] hw/xen_disk: ioreq not finished on error

login
register
mail settings
Submitter Feiran Zheng
Date March 29, 2011, 1 a.m.
Message ID <AANLkTikN+cxiGDOt03a1UPGR4ysFdGiTW3CnK1jOW4bk@mail.gmail.com>
Download mbox | patch
Permalink /patch/88708/
State New
Headers show

Comments

Feiran Zheng - March 29, 2011, 1 a.m.
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>
---
 hw/xen_disk.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
Stefano Stabellini - March 29, 2011, 10:48 a.m.
On Tue, 29 Mar 2011, Feiran Zheng wrote:
> 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.
> 

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Kevin Wolf - March 29, 2011, 11:50 a.m.
Am 29.03.2011 12:48, schrieb Stefano Stabellini:
> On Tue, 29 Mar 2011, Feiran Zheng wrote:
>> 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.
>>
> 
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 445bf03..558bf8a 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -310,7 +310,7 @@  static int ioreq_runio_qemu_sync(struct ioreq *ioreq)
     off_t pos;

     if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
-	goto err;
+	goto err_no_map;
     if (ioreq->presync)
 	bdrv_flush(blkdev->bs);

@@ -364,6 +364,9 @@  static int ioreq_runio_qemu_sync(struct ioreq *ioreq)
     return 0;

 err:
+    ioreq_unmap(ioreq);
+err_no_map:
+    ioreq_finish(ioreq);
     ioreq->status = BLKIF_RSP_ERROR;
     return -1;
 }
@@ -393,7 +396,7 @@  static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
     struct XenBlkDev *blkdev = ioreq->blkdev;

     if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
-	goto err;
+	goto err_no_map;

     ioreq->aio_inflight++;
     if (ioreq->presync)
@@ -427,6 +430,9 @@  static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
     return 0;

 err:
+    ioreq_unmap(ioreq);
+err_no_map:
+    ioreq_finish(ioreq);
     ioreq->status = BLKIF_RSP_ERROR;
     return -1;
 }