From 86710c9bb24111c9f1c9a2ec9623c89b987e93a8 Mon Sep 17 00:00:00 2001 From: yuxiaojun Date: Tue, 28 Nov 2023 17:14:05 +0800 Subject: [PATCH 1/3] fix: memory leak: buf Signed-off-by: yuxiaojun --- hw/mcu/sony/cxd56/mkspk/mkspk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/mcu/sony/cxd56/mkspk/mkspk.c b/hw/mcu/sony/cxd56/mkspk/mkspk.c index 3feb235f6e..78d98a08e6 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); From e03774be8828ac9b3cb9bfd5e80c769d338a8e0f Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 16 Apr 2024 12:04:43 +0700 Subject: [PATCH 2/3] skip symlink in pre-commit --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4071ec3267..bba217cc99 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,9 @@ repos: exclude: | (?x)^( .idea/| - hw/bsp/mcx/sdk/ + hw/bsp/mcx/sdk/| + docs/contributing/code_of_conduct.rst| + docs/info/contributors.rst ) - id: forbid-submodules From 10a86172ec5d1dd31122346776bff1f4ea1574e4 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 16 Apr 2024 12:06:26 +0700 Subject: [PATCH 3/3] fix pre-commit --- hw/mcu/sony/cxd56/mkspk/mkspk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mcu/sony/cxd56/mkspk/mkspk.c b/hw/mcu/sony/cxd56/mkspk/mkspk.c index 78d98a08e6..24e0cf77bb 100644 --- a/hw/mcu/sony/cxd56/mkspk/mkspk.c +++ b/hw/mcu/sony/cxd56/mkspk/mkspk.c @@ -358,7 +358,7 @@ int main(int argc, char **argv) free(elf->data); } free(elf); - + c = cipher_init(vmk, NULL); cipher_calc_cmac(c, spkimage, size, (uint8_t *) spkimage + size);