From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkDhK-000231-E2 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkCeF-0006M3-Kj for qemu-devel@nongnu.org; Fri, 31 Oct 2014 09:53:57 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:46765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkCeF-0006LA-FO for qemu-devel@nongnu.org; Fri, 31 Oct 2014 09:53:51 -0400 Received: by mail-wi0-f170.google.com with SMTP id q5so1341347wiv.5 for ; Fri, 31 Oct 2014 06:53:50 -0700 (PDT) From: Eric Auger Date: Fri, 31 Oct 2014 13:53:29 +0000 Message-Id: <1414763612-4939-4-git-send-email-eric.auger@linaro.org> In-Reply-To: <1414763612-4939-1-git-send-email-eric.auger@linaro.org> References: <1414763612-4939-1-git-send-email-eric.auger@linaro.org> Subject: [Qemu-devel] [PATCH v4 3/6] hw/arm/boot: do not free VirtBoardInfo fdt in arm_load_dtb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com, kim.phillips@freescale.com, a.rigo@virtualopensystems.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com Cc: peter.maydell@linaro.org, patches@linaro.org, eric.auger@linaro.org, will.deacon@arm.com, stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com, alex.williamson@redhat.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu Currently arm_load_dtb frees the fdt handle whatever it is allocated from load_device_tree or allocated externally. When adding dynamic sysbus nodes after the first dtb load, we would like to reuse the fdt used during the first load instead of re-creating the whole device tree. If the fdt is destroyed, this is not possible. Signed-off-by: Eric Auger --- hw/arm/boot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 9f0662e..0e4b078 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -427,12 +427,16 @@ int arm_load_dtb(const struct arm_boot_info *binfo) */ rom_add_blob_fixed("dtb", fdt, size, binfo->dtb_start); - g_free(fdt); + if (binfo->dtb_filename) { + g_free(fdt); + } return size; fail: - g_free(fdt); + if (binfo->dtb_filename) { + g_free(fdt); + } return -1; } -- 1.8.3.2