Skip to contentSkip to conversation

9pfs: fix memory leak in v9fs_link

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

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 9pfs: fix memory leak in v9fs_link

From: Li Qiang <[email protected]>

In v9fs_link dispatch function, it doesn't put the 'oldfidp' fid object, this will make the 'oldfidp->ref' never reach to 0, thus leading a memory leak issue. This patch fix this.

---
 hw/9pfs/9p.c | 1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p.c +1 -0
index 8b50bfb..29f8b7a 100644
@@ -2413,6 +2413,7 @@ static void v9fs_link(void *opaque)
     if (!err) {
         err = offset;
     }
+    put_fid(pdu, oldfidp);
 out:
     put_fid(pdu, dfidp);
 out_nofid:
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Wed, 12 Oct 2016 00:12:48 -0700 Li Qiang <[email protected]> wrote:

From: Li Qiang <[email protected]>

In v9fs_link dispatch function, it doesn't put the 'oldfidp' fid object, this will make the 'oldfidp->ref' never reach to 0, thus leading a memory leak issue. This patch fix this.

---

Good catch!

Quoted 15 lines
 hw/9pfs/9p.c | 1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p.c +1 -0
index 8b50bfb..29f8b7a 100644
@@ -2413,6 +2413,7 @@ static void v9fs_link(void *opaque)
     if (!err) {
         err = offset;
     }
+    put_fid(pdu, oldfidp);
 out:
     put_fid(pdu, dfidp);
 out_nofid: