From 8742e2a9238da49aeb4dd1afa9603fdc22697422 Mon Sep 17 00:00:00 2001 From: Hsuan Ting Chen Date: Thu, 17 Sep 2020 15:51:34 +0800 Subject: libpayload: free: Separate NULL check out for clarity Separate the validity check of calling free(NULL) for clarity. BUG=b:168441735 TEST=emerge-puff libpayload Change-Id: I0dc355553410bbe59e658945fb40c05f5f709380 Signed-off-by: Hsuan Ting Chen Reviewed-on: https://review.coreboot.org/c/coreboot/+/45465 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Hung-Te Lin Reviewed-by: Yu-Ping Wu --- payloads/libpayload/libc/malloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c index 48bf32ee3b..20f9ef38e1 100644 --- a/payloads/libpayload/libc/malloc.c +++ b/payloads/libpayload/libc/malloc.c @@ -246,6 +246,10 @@ void free(void *ptr) hdrtype_t hdr; struct memory_type *type = heap; + /* No action occurs on NULL. */ + if (ptr == NULL) + return; + /* Sanity check. */ if (ptr < type->start || ptr >= type->end) { type = dma; -- cgit v1.2.3