9pfs: fix memory leak in v9fs_write
PATCH 1/1 9pfs: fix memory leak in v9fs_write
From: Li Qiang <[email protected]>
If an error occurs when marshal the transfer length to the guest, the v9fs_write doesn't free a IO vector, thus leading a memory leak. This patch fix this.
Signed-off-by Li Qiang <[email protected]>
--- fsdev/9p-iov-marshal.c | 2 +- hw/9pfs/9p.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fsdev/9p-iov-marshal.c +1 -1
@@ -125,7 +125,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, str->data =g_malloc (str->size +1 ); copied =v9fs_unpack (str->data, out_sg, out_num, offset, str->size); -if (copied >0 ) { +if (copied >=0 ) { str->data[str->size] =0 ; }else {v9fs_string_free (str);
hw/9pfs/9p.c +1 -1
@@ -2090,7 +2090,7 @@ static void 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);
Signature · 1 line
1.8.3.1