severe memory leak caused by broken palette_destroy() function
A message that is not in the archive (sent off-list or not yet received): 942456759.505022.1301042552254.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com
PATCH v2 1/1 severe memory leak caused by broken palette_destroy() function
This is version 2 of the patch that I originally posted in:
http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02063.html
[Sorry, I missed to include the keyword 'PATCH' in the subject
of the original post.]
The following commit breaks the code of the function palette_destroy().
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268
The broken code causes a severe memory leak of 'VncPalette' structures because it never frees anything:
70 void palette_destroy(VncPalette *palette)
71 {
72 if (palette == NULL) {
73 qemu_free(palette);
74 }
75 }Version 2 of the patch calls qemu_free() unconditionally.
ui/vnc-palette.c renamed from ui/vnc-palette.c.orig0 +1 -3
@@ -69,9 +69,7 @@ void palette_init(VncPalette *palette, svoid palette_destroy (VncPalette *palette) { -if (palette ==NULL ) { -qemu_free (palette); - } +qemu_free (palette); }int palette_put (VncPalette *palette,uint32_t color)
Quoted 21 lines · Ulrich Obergfell
This is version 2 of the patch that I originally posted in:
http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02063.html
[Sorry, I missed to include the keyword 'PATCH' in the subject
of the original post.]The following commit breaks the code of the function
palette_destroy().http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268
The broken code causes a severe memory leak of 'VncPalette' structures because it never frees anything:
70 void palette_destroy(VncPalette *palette) 71 { 72 if (palette == NULL) { 73 qemu_free(palette); 74 } 75 }
Quoted 3 lines
Version 2 of the patch calls
qemu_free()unconditionally.Signed-off-by Ulrich Obergfell <[email protected]>
Ouchhhhhhhhhhhhhhh
A new reason to never ever test if pointer is != NULL before calling free.
Good catch.
Quoted 22 lines · Ulrich Obergfell
This is version 2 of the patch that I originally posted in:
http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02063.html
[Sorry, I missed to include the keyword 'PATCH' in the subject of the original post.]
The following commit breaks the code of the function
palette_destroy().http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268
The broken code causes a severe memory leak of 'VncPalette' structures because it never frees anything:
70 void
palette_destroy(VncPalette *palette)
71 {
72 if (palette == NULL) {
73qemu_free(palette);
74 }
75 }
Quoted 3 lines
Version 2 of the patch calls
qemu_free()unconditionally.Signed-off-by Ulrich Obergfell <[email protected]>
Looks good.
Anthony Liguori
AppliedQuoted 22 lines · Stefan Hajnoczi
Quoted 21 lines · Ulrich Obergfell
This is version 2 of the patch that I originally posted in:
http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02063.html
[Sorry, I missed to include the keyword 'PATCH' in the subject
of the original post.]The following commit breaks the code of the function
palette_destroy().http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268
The broken code causes a severe memory leak of 'VncPalette' structures because it never frees anything:
70 void palette_destroy(VncPalette *palette) 71 { 72 if (palette == NULL) { 73 qemu_free(palette); 74 } 75 }
Quoted 4 lines
Quoted 3 lines
Version 2 of the patch calls
qemu_free()unconditionally.Signed-off-by Ulrich Obergfell<[email protected]>Looks good.
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 1 line
Reviewed-by Stefan Hajnoczi<[email protected]>