qemu-nbd.c : fix memory leak
PATCH 1/1 qemu-nbd.c : fix memory leak
--- qemu-nbd.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
qemu-nbd.c +3 -1
@@ -500,8 +500,10 @@ int main(int argc, char **argv) sharing_fds[0 ] =tcp_socket_incoming (bindto, port); } -if (sharing_fds[0 ] ==-1 ) +if (sharing_fds[0 ] ==-1 ) { +g_free (sharing_fds);return 1 ; + }if (device) {int ret;
Signature · 1 line
1.7.4.1
Quoted 11 lines · Li Zhi Hui
Signed-off-by Li Zhi Hui<[email protected]>--- qemu-nbd.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)qemu-nbd.c +0
-0@@ -500,8 +500,10 @@ int main(int argc, char **argv) sharing_fds[0 ] =tcp_socket_incoming (bindto, port);
qemu-nbd.c int main(int argc, char **argv) · line 509
Quoted 10 lines
qemu-nbd.c +3
-1} -if (sharing_fds[0 ] ==-1 ) +if (sharing_fds[0 ] ==-1 ) { +g_free (sharing_fds);return 1 ; + }if (device) {int ret;
Zhihui,
Kernel should free all memory used by the process after it exits. So there's no memory leak even without explicit free.
Stefan Weil
Reviewed-byAm 02.12.2011 08:28, schrieb Mark Wu:
Quoted 20 lines · Li Zhi Hui
Quoted 19 lines
Signed-off-by Li Zhi Hui<[email protected]>--- qemu-nbd.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)qemu-nbd.c +3
-1@@ -500,8 +500,10 @@ int main(int argc, char **argv) sharing_fds[0 ] =tcp_socket_incoming (bindto, port); } -if (sharing_fds[0 ] ==-1 ) +if (sharing_fds[0 ] ==-1 ) { +g_free (sharing_fds);return 1 ; + }
Quoted 5 lines
qemu-nbd.c int main(int argc, char **argv) · line 509
Quoted 2 lines
qemu-nbd.c +0
-0if (device) {int ret;Zhihui,
Kernel should free all memory used by the process after it exits. So there's no memory leak even without explicit free.
That's correct. Nevertheless fixing this helps to find other more important memory leaks with static or dynamic code analyzers like cppcheck or valgrind.
Quoted 11 lines · Stefan Weil
Quoted 11 lines
qemu-nbd.c int main(int argc, char **argv) · line 509
Quoted 9 lines
qemu-nbd.c +3
-1-if (sharing_fds[0 ] ==-1 ) +if (sharing_fds[0 ] ==-1 ) { +g_free (sharing_fds);return 1 ; + }if (device) {int ret;Zhihui,
Quoted 8 lines
Quoted 2 lines
Kernel should free all memory used by the process after it exits. So there's no memory leak even without explicit free.
That's correct. Nevertheless fixing this helps to find other more important memory leaks with static or dynamic code analyzers like cppcheck or valgrind.
Reviewed-by Stefan Weil <[email protected]>
Please hold off, I'm about to introduce large changes to qemu-nbd for asynchronous I/O (including getting rid of sharing_fds in favor of the main loop) and and I'd rather avoid gratuitous conflicts.
Paolo
Quoted 19 lines · Paolo Bonzini
Quoted 18 lines · Stefan Weil
Quoted 7 lines
Quoted 7 lines
qemu-nbd.c +3
-1-if (sharing_fds[0 ] ==-1 ) +if (sharing_fds[0 ] ==-1 ) { +g_free (sharing_fds);return 1 ; + }Quoted 6 lines
Quoted 2 lines
if (device) { int ret;Zhihui,
Kernel should free all memory used by the process after it exits. So there's no memory leak even without explicit free.
That's correct. Nevertheless fixing this helps to find other more important memory leaks with static or dynamic code analyzers like cppcheck or valgrind.
Quoted 5 lines
Quoted 1 line
Reviewed-by Stefan Weil <[email protected]>Please hold off, I'm about to introduce large changes to qemu-nbd for asynchronous I/O (including getting rid of
sharing_fdsin favor of the main loop) and and I'd rather avoid gratuitous conflicts.
Okay, let's wait for Paolo's changes.
Stefan
Thank you very much!