Fix minor memory leak
PATCH 1/1 Fix minor memory leak
Fix a memory leak. No big deal, since it happens only a bounded # of times at startup (as far as I can tell) but it makes valgrind complain.
I sent this here since qemu doesn't have the code in question (it allocates buf on the stack, and thus guess_disk_lchs() usually won't work with O_DIRECT).
qemu/block.c +3 -1
@@ -771,8 +771,10 @@ static int guess_disk_lchs(BlockDriverState *bs,bdrv_get_geometry (bs, &nb_sectors); ret =bdrv_read (bs,0 , buf,1 ); -if (ret <0 ) +if (ret <0 ) { +qemu_free (buf);return -1 ; + }/* test msdos magic */ if (buf[510 ] !=0x55 || buf[511 ] !=0xaa ) {qemu_free (buf);
Quoted 6 lines · Nolan
Fix a memory leak. No big deal, since it happens only a bounded # of times at startup (as far as I can tell) but it makes valgrind complain.
I sent this here since qemu doesn't have the code in question (it allocates buf on the stack, and thus
guess_disk_lchs()usually won't work withO_DIRECT).
Nolan,
block-raw-posix.c raw_pread() handles alignment for O_DIRECT, so it seems the changes in qemu-kvm are now unnecessary. Can you send a patch to match upstream QEMU, with the buf on stack?
TIA
Quoted 24 lines
Signed-off-by Nolan Leake nolan <at> sigbus.netqemu/block.c +3
-2@@ -771,8 +771,10 @@ static int guess_disk_lchs(BlockDriverState *bs,bdrv_get_geometry (bs, &nb_sectors); ret =bdrv_read (bs,0 , buf,1 ); -if (ret <0 ) +if (ret <0 ) { +qemu_free (buf);return -1 ; + }/* test msdos magic */ if (buf[510 ] !=0x55 || buf[511 ] !=0xaa ) {qemu_free (buf); --To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html