Patchwork fix memory leak when we uninit a drive

login
register
mail settings
Submitter Wen Congyang
Date Feb. 16, 2011, 2:23 a.m.
Message ID <4D5B353E.2060500@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/83324/
State New
Headers show

Comments

Wen Congyang - Feb. 16, 2011, 2:23 a.m.
We alloc memory for dinfo->id, so we should free it in
the function drive_uninit().

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

---
 blockdev.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Markus Armbruster - Feb. 16, 2011, 9:43 a.m.
Wen Congyang <wency@cn.fujitsu.com> writes:

> We alloc memory for dinfo->id, so we should free it in
> the function drive_uninit().

Already fixed in Kevin's block tree and 0.14-rc2 (commit e5f1c196),
although not yet in stable.

Thanks anyway!

Patch

diff --git a/blockdev.c b/blockdev.c
index ecfadc1..1333a4e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -183,6 +183,8 @@  static void drive_uninit(DriveInfo *dinfo)
     qemu_opts_del(dinfo->opts);
     bdrv_delete(dinfo->bdrv);
     QTAILQ_REMOVE(&drives, dinfo, next);
+    if (dinfo->id)
+        qemu_free(dinfo->id);
     qemu_free(dinfo);
 }