Skip to contentSkip to conversation

9pfs: fix potential host memory leak in v9fs_read

PATCH In review Li Qiang 2 participants 3 messages Sep 27, 2016 – Oct 10, 2016

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 9pfs: fix potential host memory leak in v9fs_read

From: Li Qiang <[email protected]>

In 9pfs read dispatch function, it doesn't free two QEMUIOVector object thus causing potential memory leak. This patch avoid this.

---
 hw/9pfs/9p.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +3 -2
index 119ee58..543a791 100644
@@ -1826,14 +1826,15 @@ static void v9fs_read(void *opaque)
             if (len < 0) {
                 /* IO error return the error */
                 err = len;
-                goto out;
+                goto out_free_iovec;
             }
         } while (count < max_count && len > 0);
         err = pdu_marshal(pdu, offset, "d", count);
         if (err < 0) {
-            goto out;
+            goto out_free_iovec;
         }
         err += offset + count;
+out_free_iovec:
         qemu_iovec_destroy(&qiov);
         qemu_iovec_destroy(&qiov_full);
     } else if (fidp->fid_type == P9_FID_XATTR) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 7 lines · On Tue, 27 Sep 2016 04:58:46 -0700 Li Qiang <[email protected]> wrote:

From: Li Qiang <[email protected]>

In 9pfs read dispatch function, it doesn't free two QEMUIOVector object thus causing potential memory leak. This patch avoid this.

---

When you post an updated version of a patch, you should:

- add a version in the subject

[PATCH v2] 9pfs: fix potential host memory leak in v9fs_read

- list the changes since the previous version under the --- after your Signed-off-by

Anyway, the change is ok, I'll push this to my tree.

Thanks.

--
Greg

Quoted 25 lines
 hw/9pfs/9p.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +3 -2
index 119ee58..543a791 100644
@@ -1826,14 +1826,15 @@ static void v9fs_read(void *opaque)
             if (len < 0) {
                 /* IO error return the error */
                 err = len;
-                goto out;
+                goto out_free_iovec;
             }
         } while (count < max_count && len > 0);
         err = pdu_marshal(pdu, offset, "d", count);
         if (err < 0) {
-            goto out;
+            goto out_free_iovec;
         }
         err += offset + count;
+out_free_iovec:
         qemu_iovec_destroy(&qiov);
         qemu_iovec_destroy(&qiov_full);
     } else if (fidp->fid_type == P9_FID_XATTR) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Li Qiang
Quoted 7 lines · On Tue, 27 Sep 2016 04:58:46 -0700 Li Qiang <[email protected]> wrote:

From: Li Qiang <[email protected]>

In 9pfs read dispatch function, it doesn't free two QEMUIOVector object thus causing potential memory leak. This patch avoid this.

---

Quoted 25 lines
 hw/9pfs/9p.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +3 -2
index 119ee58..543a791 100644
@@ -1826,14 +1826,15 @@ static void v9fs_read(void *opaque)
             if (len < 0) {
                 /* IO error return the error */
                 err = len;
-                goto out;
+                goto out_free_iovec;
             }
         } while (count < max_count && len > 0);
         err = pdu_marshal(pdu, offset, "d", count);
         if (err < 0) {
-            goto out;
+            goto out_free_iovec;
         }
         err += offset + count;
+out_free_iovec:
         qemu_iovec_destroy(&qiov);
         qemu_iovec_destroy(&qiov_full);
     } else if (fidp->fid_type == P9_FID_XATTR) {