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>
This commit is contained in:
parent
d2b2a18307
commit
5ab67f9ef8
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue