9pfs: fix memory leak in v9fs_write
authorLi Qiang <liqiang6-s@360.cn>
Mon, 17 Oct 2016 12:13:58 +0000 (14:13 +0200)
committerGreg Kurz <groug@kaod.org>
Mon, 17 Oct 2016 12:13:58 +0000 (14:13 +0200)
If an error occurs when marshalling the transfer length to the guest, the
v9fs_write() function doesn't free an IO vector, thus leading to a memory
leak. This patch fixes the issue.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Greg Kurz <groug@kaod.org>
[groug, rephrased the changelog]
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/9pfs/9p.c

index d43a55223492ad8fc824d62deda946dad2734f78..e88cf257a2b9f2d11cbad87893ff8f028391c6d8 100644 (file)
@@ -2090,7 +2090,7 @@ static void coroutine_fn v9fs_write(void *opaque)
     offset = 7;
     err = pdu_marshal(pdu, offset, "d", total);
     if (err < 0) {
-        goto out;
+        goto out_qiov;
     }
     err += offset;
     trace_v9fs_write_return(pdu->tag, pdu->id, total, err);