OSDN Git Service

hw/nios2:fix leak of fdevice tree blob
authorChen Qun <kuhn.chenqun@huawei.com>
Tue, 18 Feb 2020 09:11:52 +0000 (17:11 +0800)
committerLaurent Vivier <laurent@vivier.eu>
Wed, 19 Feb 2020 09:32:50 +0000 (10:32 +0100)
The device tree blob returned by load_device_tree is malloced.
We should free it after cpu_physical_memory_write().

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200218091154.21696-2-kuhn.chenqun@huawei.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
hw/nios2/boot.c

index 46b8349..88224aa 100644 (file)
@@ -109,6 +109,7 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize,
     }
 
     cpu_physical_memory_write(bi.fdt, fdt, fdt_size);
+    g_free(fdt);
     return fdt_size;
 }