Attention is currently required from: Brandon Weeks, Jakub Czapiga, Julius Werner, Patrick Georgi.

Patrick Georgi uploaded patch set #3 to this change.

View Change

malloc/memalign: Return NULL if the request is too large

It's what this function family is defined to do, we currently don't
usually run into the case (see: not too many die() instances going
around), it's more useful to try to recover, and the JPEG parser can run
into it if the work buffer size exceeds the remaining heap, whereas its
sole user (the bootsplash code) knows what to do when seeing a NULL.

Use xmalloc() if you want an allocation that either works or dies.

tl;dr: That code path isn't usually taken. Right now it crashes. With
this patch it _might_ survive. There is a use-case for doing it like
that now.

Change-Id: I262fbad7daae0ca3aab583fda00665a2592deaa8
Signed-off-by: Patrick Georgi <patrick@coreboot.org>
---
M src/lib/malloc.c
M tests/lib/malloc-test.c
2 files changed, 8 insertions(+), 11 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/26/80226/3

To view, visit change 80226. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I262fbad7daae0ca3aab583fda00665a2592deaa8
Gerrit-Change-Number: 80226
Gerrit-PatchSet: 3
Gerrit-Owner: Patrick Georgi <patrick@coreboot.org>
Gerrit-Reviewer: Brandon Weeks <bweeks@google.com>
Gerrit-Reviewer: Eric Lai <ericllai@google.com>
Gerrit-Reviewer: Jakub Czapiga <czapiga@google.com>
Gerrit-Reviewer: Julius Werner <jwerner@chromium.org>
Gerrit-Reviewer: Martin L Roth <gaumless@gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-Attention: Patrick Georgi <patrick@coreboot.org>
Gerrit-Attention: Jakub Czapiga <czapiga@google.com>
Gerrit-Attention: Brandon Weeks <bweeks@google.com>
Gerrit-Attention: Julius Werner <jwerner@chromium.org>
Gerrit-MessageType: newpatchset