carlwgeorge / rpms / qemu

Forked from rpms/qemu a year ago
Clone
4d7edd7
From: Li Qiang <liqiang6-s@360.cn>
4d7edd7
Date: Mon, 17 Oct 2016 14:13:58 +0200
4d7edd7
Subject: [PATCH] 9pfs: fix memory leak in v9fs_xattrcreate
4d7edd7
4d7edd7
The 'fs.xattr.value' field in V9fsFidState object doesn't consider the
4d7edd7
situation that this field has been allocated previously. Every time, it
4d7edd7
will be allocated directly. This leads to a host memory leak issue if
4d7edd7
the client sends another Txattrcreate message with the same fid number
4d7edd7
before the fid from the previous time got clunked.
4d7edd7
4d7edd7
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
4d7edd7
Reviewed-by: Greg Kurz <groug@kaod.org>
4d7edd7
[groug, updated the changelog to indicate how the leak can occur]
4d7edd7
Signed-off-by: Greg Kurz <groug@kaod.org>
4d7edd7
4d7edd7
(cherry picked from commit ff55e94d23ae94c8628b0115320157c763eb3e06)
4d7edd7
---
4d7edd7
 hw/9pfs/9p.c | 1 +
4d7edd7
 1 file changed, 1 insertion(+)
4d7edd7
4d7edd7
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
4d7edd7
index 0735246..54e5ed4 100644
4d7edd7
--- a/hw/9pfs/9p.c
4d7edd7
+++ b/hw/9pfs/9p.c
4d7edd7
@@ -3259,6 +3259,7 @@ static void v9fs_xattrcreate(void *opaque)
4d7edd7
     xattr_fidp->fs.xattr.flags = flags;
4d7edd7
     v9fs_string_init(&xattr_fidp->fs.xattr.name);
4d7edd7
     v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
4d7edd7
+    g_free(xattr_fidp->fs.xattr.value);
4d7edd7
     xattr_fidp->fs.xattr.value = g_malloc0(size);
4d7edd7
     err = offset;
4d7edd7
     put_fid(pdu, file_fidp);