From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdM82-0008Mc-08 for qemu-devel@nongnu.org; Wed, 01 Apr 2015 13:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdM7v-0001dv-Ro for qemu-devel@nongnu.org; Wed, 01 Apr 2015 13:08:33 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:33290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdM7v-0001cG-LT for qemu-devel@nongnu.org; Wed, 01 Apr 2015 13:08:27 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YdM7m-0002xl-IV for qemu-devel@nongnu.org; Wed, 01 Apr 2015 18:08:18 +0100 From: Peter Maydell Date: Wed, 1 Apr 2015 18:08:11 +0100 Message-Id: <1427908098-11358-2-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1427908098-11358-1-git-send-email-peter.maydell@linaro.org> References: <1427908098-11358-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 1/8] hw/arm/highbank: Fix resource leak and wrong image loading List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Stefan Weil Coverity reports a resource leak for sysboot_filename which is allocated by qemu_find_file. In addition, that name is used to get the size of the image, but a different image name was used to load it. In addition, instead of passing the maximum allowed image size the actual image size was passed to load_image_targphys. Fix all three issues. Signed-off-by: Stefan Weil Message-id: 1426326781-2488-1-git-send-email-sw@weilnetz.de Signed-off-by: Peter Maydell --- hw/arm/highbank.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index ddd10dc..07cb4e0 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -278,8 +278,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) if (bios_name != NULL) { sysboot_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (sysboot_filename != NULL) { - uint32_t filesize = get_image_size(sysboot_filename); - if (load_image_targphys("sysram.bin", 0xfff88000, filesize) < 0) { + if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000) < 0) { hw_error("Unable to load %s\n", bios_name); } g_free(sysboot_filename); -- 1.9.1