summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2020-11-06 18:58:23 +0100
committerPhilippe Mathieu-Daudé2020-11-09 00:40:44 +0100
commitbf4ee88ab63fcf2dcb75f0d68cc6c8d2edb68212 (patch)
treed06a2bedb0528dbb144c7ab1ab8bca14723b4a04
parenttarget/mips: Fix PageMask with variable page size (diff)
downloadqemu-bf4ee88ab63fcf2dcb75f0d68cc6c8d2edb68212.tar.gz
qemu-bf4ee88ab63fcf2dcb75f0d68cc6c8d2edb68212.tar.xz
qemu-bf4ee88ab63fcf2dcb75f0d68cc6c8d2edb68212.zip
hw/mips/boston: Fix memory leak in boston_fdt_filter() error-handling paths
Coverity points out that the error-handling paths in the boston_fdt_filter() function don't free the fdt that was allocated. Fix the leak by using g_autofree. Fixes: Coverity CID 1432275 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20201106175823.1650-1-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-rw-r--r--hw/mips/boston.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 3356d7a681..3d40867dc4 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -349,11 +349,9 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
MachineState *machine = s->mach;
const char *cmdline;
int err;
- void *fdt;
- size_t fdt_sz, ram_low_sz, ram_high_sz;
-
- fdt_sz = fdt_totalsize(fdt_orig) * 2;
- fdt = g_malloc0(fdt_sz);
+ size_t ram_low_sz, ram_high_sz;
+ size_t fdt_sz = fdt_totalsize(fdt_orig) * 2;
+ g_autofree void *fdt = g_malloc0(fdt_sz);
err = fdt_open_into(fdt_orig, fdt, fdt_sz);
if (err) {
@@ -380,7 +378,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
s->fdt_base = *load_addr;
- return fdt;
+ return g_steal_pointer(&fdt);
}
static const void *boston_kernel_filter(void *opaque, const void *kernel,