qemu-io: Fix memory leak
PATCH 1/1 qemu-io: Fix memory leak
qemu-io leaks the request buffer whenever the read or write function isn't executed completely down the "normal" code path.
Signed-off-by Kevin Wolf <[email protected]>
--- qemu-io.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
qemu-io.c +6 -4
@@ -334,7 +334,7 @@ read_f(int argc, char **argv)if (cnt <0 ) {printf ("read failed: %s\n" ,strerror (-cnt)); -return 0 ; + goto out; }if (Pflag) {
@@ -349,7 +349,7 @@ read_f(int argc, char **argv) }if (qflag) -return 0 ; + goto out;if (vflag)dump_buffer (buf, offset, count);
@@ -358,6 +358,7 @@ read_f(int argc, char **argv) t2 =tsub (t2, t1);print_report ("read" , &t2, offset, count, total, cnt, Cflag); +out:qemu_io_free (buf);return 0 ;
@@ -632,16 +633,17 @@ write_f(int argc, char **argv)if (cnt <0 ) {printf ("write failed: %s\n" ,strerror (-cnt)); -return 0 ; + goto out; }if (qflag) -return 0 ; + goto out;/* Finally, report back -- -C gives a parsable format */ t2 =tsub (t2, t1);print_report ("wrote" , &t2, offset, count, total, cnt, Cflag); +out:qemu_io_free (buf);return 0 ;
Signature · 1 line
1.6.0.6
Quoted 2 lines · Kevin Wolf
qemu-io leaks the request buffer whenever the read or write function isn't executed completely down the "normal" code path.
Looks good. The same problems also happens in the vectored and aio read/write command, I'll cook up a patch to fix those.