summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuxiaojun <[email protected]>2023-11-28 17:14:05 +0800
committerhathach <[email protected]>2024-04-16 12:02:14 +0700
commit86710c9bb24111c9f1c9a2ec9623c89b987e93a8 (patch)
treeee656efb1da7a221da34de8bfe4562118e1dc915
parent178c4144ad7c625fd7e67eff79fd858f4f2ad7be (diff)
fix: memory leak: buf
Signed-off-by: yuxiaojun <[email protected]>
-rw-r--r--hw/mcu/sony/cxd56/mkspk/mkspk.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/mcu/sony/cxd56/mkspk/mkspk.c b/hw/mcu/sony/cxd56/mkspk/mkspk.c
index 3feb235f6..78d98a08e 100644
--- a/hw/mcu/sony/cxd56/mkspk/mkspk.c
+++ b/hw/mcu/sony/cxd56/mkspk/mkspk.c
@@ -183,6 +183,7 @@ static struct elf_file *load_elf(const char *filename)
buf = (char *)malloc(fsize);
if (!buf)
{
+ free(ef);
fclose(fp);
return NULL;
}
@@ -191,6 +192,8 @@ static struct elf_file *load_elf(const char *filename)
fclose(fp);
if (ret != 1)
{
+ free(ef);
+ free(buf);
return NULL;
}
@@ -351,7 +354,11 @@ int main(int argc, char **argv)
}
spkimage = create_image(elf, args->core, args->savename, &size);
+ if(elf->data) {
+ free(elf->data);
+ }
free(elf);
+
c = cipher_init(vmk, NULL);
cipher_calc_cmac(c, spkimage, size, (uint8_t *) spkimage + size);