summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakub Czapiga <jacz@semihalf.com>2021-05-24 13:33:07 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-05-26 12:33:25 +0000
commit5ab67f9ef8654ebf51b27441e8f01b9be4553161 (patch)
treed14d6fc004c8573908169e16287b3d744977eed8 /tests
parentd2b2a183075ad0c8e3b505541b7055c90a802ded (diff)
tests/lib/memset-test: Add missing malloc check and free on error
Coverity found resource leak in test setup function in error block. Add malloc result check and free in error handling to silence Coverity. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Found-by: Coverity CID 1446760 Change-Id: Icf746df27167047fa3cf8f5df09fced20863f76d Reviewed-on: https://review.coreboot.org/c/coreboot/+/54874 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/memset-test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/lib/memset-test.c b/tests/lib/memset-test.c
index 2dde2b349d..7d888a68e1 100644
--- a/tests/lib/memset-test.c
+++ b/tests/lib/memset-test.c
@@ -16,10 +16,9 @@ struct memset_test_state {
static int setup_test(void **state)
{
struct memset_test_state *s = malloc(sizeof(struct memset_test_state));
-
u8 *buf = malloc(MEMSET_BUFFER_SZ);
u8 *helper_buf = malloc(MEMSET_BUFFER_SZ);
- if (!buf || !helper_buf)
+ if (!s || !buf || !helper_buf)
goto error;
s->base_buffer = buf;
@@ -31,6 +30,7 @@ static int setup_test(void **state)
error:
free(buf);
free(helper_buf);
+ free(s);
return -1;
}