Skip to contentSkip to conversation

9pfs: fix memory leak in v9fs_write

PATCH In review Li Qiang 2 participants 2 messages Oct 12, 2016

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH v2 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 an IO vector, thus leading a memory leak. This patch fix this.

---
 hw/9pfs/9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index 8b50bfb..c8cf8c2 100644
@@ -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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · On Wed, 12 Oct 2016 06:10:56 -0700 Li Qiang <[email protected]> wrote:

From: Li Qiang <[email protected]>

If an error occurs when marshal the transfer length to the guest, the v9fs_write doesn't free an IO vector, thus leading a memory leak. This patch fix this.

---

Good catch again!

Quoted 16 lines
 hw/9pfs/9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index 8b50bfb..c8cf8c2 100644
@@ -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);