block/qcow.c: Fix memory leak in qcow_create()
PATCH 1/1 block/qcow.c: Fix memory leak in qcow_create()
Coverity points out that the code path in qcow_create() for the magic "fat:" backing file name leaks the memory used to store the filename (CID 1307771). Free the memory before we overwrite the pointer.
--- block/qcow.c | 1 + 1 file changed, 1 insertion(+)
block/qcow.c +1 -0
@@ -852,6 +852,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) header_size += backing_filename_len; }else {/* special backing file for vvfat */ +g_free (backing_file); backing_file =NULL ; } header.cluster_bits =9 ;/* 512 byte cluster to avoid copying
Signature · 1 line
2.7.4
Quoted 9 lines · Peter Maydell
Coverity points out that the code path in
qcow_create()for the magic "fat:" backing file name leaks the memory used to store the filename (CID 1307771). Free the memory before we overwrite the pointer.Signed-off-by Peter Maydell <[email protected]>--- block/qcow.c | 1 + 1 file changed, 1 insertion(+)
Quoted 14 lines
block/qcow.c +1
-0@@ -852,6 +852,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) header_size += backing_filename_len; }else {/* special backing file for vvfat */ +g_free (backing_file); backing_file =NULL ; } header.cluster_bits =9 ;/* 512 byte cluster to avoid copying
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 6 lines · Peter Maydell
Coverity points out that the code path in
qcow_create()for the magic "fat:" backing file name leaks the memory used to store the filename (CID 1307771). Free the memory before we overwrite the pointer.Signed-off-by Peter Maydell <[email protected]>
Quoted 17 lines
--- block/qcow.c | 1 + 1 file changed, 1 insertion(+)block/qcow.c +1
-0@@ -852,6 +852,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) header_size += backing_filename_len; }else {/* special backing file for vvfat */ +g_free (backing_file); backing_file =NULL ; } header.cluster_bits =9 ;/* 512 byte cluster to avoid copying
Kevin Wolf
AppliedAm 05.06.2017 um 15:55 hat Peter Maydell geschrieben:
Quoted 6 lines
Coverity points out that the code path in
qcow_create()for the magic "fat:" backing file name leaks the memory used to store the filename (CID 1307771). Free the memory before we overwrite the pointer.Signed-off-by Peter Maydell <[email protected]>
Thanks, applied to the block branch.
Kevin