Received: from [140.186.70.92] (port=38606 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q33Lu-0002d6-6a for qemu-devel@nongnu.org; Fri, 25 Mar 2011 05:30:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q33Ls-0007g1-JY for qemu-devel@nongnu.org; Fri, 25 Mar 2011 05:30:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q33Ls-0007fs-7Q for qemu-devel@nongnu.org; Fri, 25 Mar 2011 05:30:40 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2P9UdQ8026916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 Mar 2011 05:30:39 -0400 From: Juan Quintela In-Reply-To: <963102742.505036.1301042754895.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> (Ulrich Obergfell's message of "Fri, 25 Mar 2011 04:45:54 -0400 (EDT)") References: <963102742.505036.1301042754895.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Date: Fri, 25 Mar 2011 10:28:58 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH v2] severe memory leak caused by broken palette_destroy() function Reply-To: quintela@redhat.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ulrich Obergfell Cc: qemu-devel@nongnu.org Ulrich Obergfell wrote: > 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. > > Signed-off-by: Ulrich Obergfell Ouchhhhhhhhhhhhhhh Reviewed-by: Juan Quintela A new reason to never ever test if pointer is != NULL before calling free. Good catch.