From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z21Vc-0001UL-Hl for qemu-devel@nongnu.org; Mon, 08 Jun 2015 14:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z21VX-0006Cc-9z for qemu-devel@nongnu.org; Mon, 08 Jun 2015 14:10:52 -0400 Received: from relay-06.andrew.cmu.edu ([128.2.157.21]:59329 helo=relay.andrew.cmu.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z21VW-0006CI-Sj for qemu-devel@nongnu.org; Mon, 08 Jun 2015 14:10:46 -0400 From: "Gabriel L. Somlo" Date: Mon, 8 Jun 2015 14:10:45 -0400 Message-Id: <1433787045-6215-3-git-send-email-somlo@cmu.edu> In-Reply-To: <1433787045-6215-1-git-send-email-somlo@cmu.edu> References: <1433787045-6215-1-git-send-email-somlo@cmu.edu> Subject: [Qemu-devel] [PATCH 2/2] fw_cfg: fix FW_CFG_BOOT_DEVICE update on ppc and sparc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, gsomlo@gmail.com, kraxel@redhat.com On ppc, sparc, and sparc64, the value of the FW_CFG_BOOT_DEVICE 16bit fw_cfg entry is repeatedly modified from a series of callbacks, which currently results in the previous value's dynamically allocated memory being leaked. This patch switches updating to the new fw_cfg_modify_i16() call, which does not cause memory leaks. Signed-off-by: Gabriel Somlo --- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/sparc/sun4m.c | 2 +- hw/sparc64/sun4u.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index a365bf9..0f3e341 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -119,7 +119,7 @@ static const MemoryRegionOps unin_ops = { static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { - fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); + fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } static uint64_t translate_kernel_address(void *opaque, uint64_t addr) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index f26133d..99879dd 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -52,7 +52,7 @@ static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { - fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); + fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } static uint64_t translate_kernel_address(void *opaque, uint64_t addr) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 8a3599c..68ac4d8 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -124,7 +124,7 @@ void DMA_register_channel (int nchan, static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { - fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); + fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } static void nvram_init(Nvram *nvram, uint8_t *macaddr, diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 6f34e87..30cfa0e 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -127,7 +127,7 @@ void DMA_register_channel (int nchan, static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { - fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); + fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size, -- 2.1.0