Jonathan Neuschäfer (j.neuschaefer@gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14244
-gerrit
commit 8a34c558b13b67b9572f1e3861ae1de79ffb8aaf Author: Jonathan Neuschäfer j.neuschaefer@gmx.net Date: Mon Apr 4 19:52:35 2016 +0200
libpayload/libc: Fix memset/sizeof usage
Since r is a pointer, memset(r, 0, sizeof(r)) would only zero the first 4 (or 8) bytes of the newly allocated struct align_region_t.
An alternative to this patch would be to use calloc, or introduce a new zalloc (zeroed allocation; a single-element calloc) and use that.
This fixes Coverity ID 1291160.
Change-Id: Ic3e3487ce749eeebf6c4836e62b8a305ad766e7e Signed-off-by: Jonathan Neuschäfer j.neuschaefer@gmx.net --- payloads/libpayload/libc/malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c index 7099e47..b7ac1a7 100644 --- a/payloads/libpayload/libc/malloc.c +++ b/payloads/libpayload/libc/malloc.c @@ -366,7 +366,7 @@ static struct align_region_t *allocate_region(int alignment, int num_elements, if (r == NULL) return NULL;
- memset(r, 0, sizeof(r)); + memset(r, 0, sizeof(*r));
if (num_elements != 0) { r->alignment = alignment;