Skip to contentSkip to conversation

block/vvfat: Fix memleaks in vvfat_close()

PATCH In review Hanna Reitz 3 participants 3 messages Feb 7, 2022 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/vvfat: Fix memleaks in vvfat_close()

qcow_filename and used_clusters are allocated in enable_write_target(), but freed only in the error path of vvfat_open(). Free them in vvfat_close(), too.

---
 block/vvfat.c | 2 ++
 1 file changed, 2 insertions(+)
block/vvfat.c +2 -0
index b2b58d93b8..811ba76e30 100644
@@ -3213,6 +3213,8 @@ static void vvfat_close(BlockDriverState *bs)
     array_free(&(s->directory));
     array_free(&(s->mapping));
     g_free(s->cluster_buffer);
+    g_free(s->qcow_filename);
+    g_free(s->used_clusters);
 
     if (s->qcow) {
         migrate_del_blocker(s->migration_blocker);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 14 lines · Hanna Reitz

qcow_filename and used_clusters are allocated in enable_write_target(), but freed only in the error path of vvfat_open(). Free them in vvfat_close(), too.

---
  block/vvfat.c | 2 ++
  1 file changed, 2 insertions(+)
block/vvfat.c +0 -0
index b2b58d93b8..811ba76e30 100644

block/vvfat.c static void vvfat_close(BlockDriverState *bs) · line 3217

Quoted 5 lines
block/vvfat.c +2 -0
@@ -3213,6 +3213,8 @@ static void vvfat_close(BlockDriverState *bs)
      array_free(&(s->directory));
      array_free(&(s->mapping));
      g_free(s->cluster_buffer);
+    g_free(s->qcow_filename);
+    g_free(s->used_clusters);

Previously posted / reviewed :)

https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/[email protected]/

#2 lore raw

Am 07.02.2022 um 16:20 hat Philippe Mathieu-Daudé geschrieben:

Quoted 23 lines · Hanna Reitz
Quoted 14 lines

qcow_filename and used_clusters are allocated in enable_write_target(), but freed only in the error path of vvfat_open(). Free them in vvfat_close(), too.

---
  block/vvfat.c | 2 ++
  1 file changed, 2 insertions(+)
block/vvfat.c +0 -0
index b2b58d93b8..811ba76e30 100644

block/vvfat.c static void vvfat_close(BlockDriverState *bs) · line 3217

Quoted 5 lines
block/vvfat.c +2 -0
@@ -3213,6 +3213,8 @@ static void vvfat_close(BlockDriverState *bs)
      array_free(&(s->directory));
      array_free(&(s->mapping));
      g_free(s->cluster_buffer);
+    g_free(s->qcow_filename);
+    g_free(s->used_clusters);

Previously posted / reviewed :)

Quoted 2 lines

https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/[email protected]/

Looks like there were questions about patch 3 and even an objection to patch 4. Do you suggest we apply only the first two patches? I think at the time I expected you would either reply or send a v2.

Kevin