From 5446bdb270be409eaf5a0a60d86ebeb2ec4358ad Mon Sep 17 00:00:00 2001 From: Jakub Czapiga Date: Thu, 10 Dec 2020 12:21:52 +0100 Subject: [PATCH] lib/fmap: Add null parameters handling Prevent null-pointer access when passed as parameter. Signed-off-by: Jakub Czapiga Change-Id: Ie712d040b1c2383dcc8884e5f779c3591ccf0163 Reviewed-on: https://review.coreboot.org/c/coreboot/+/48531 Tested-by: build bot (Jenkins) Reviewed-by: Paul Fagerburg --- src/lib/fmap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/fmap.c b/src/lib/fmap.c index 2abe138cdd..418e715b3e 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -164,6 +164,9 @@ int fmap_locate_area(const char *name, struct region *ar) struct region_device fmrd; size_t offset; + if (name == NULL || ar == NULL) + return -1; + if (find_fmap_directory(&fmrd)) return -1; @@ -206,6 +209,9 @@ int fmap_find_region_name(const struct region * const ar, struct region_device fmrd; size_t offset; + if (name == NULL || ar == NULL) + return -1; + if (find_fmap_directory(&fmrd)) return -1;