diff options
author | edisonhello <edisonhello@google.com> | 2021-08-06 18:06:15 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-10 09:28:35 +0000 |
commit | 302794156d6689d97eba7d7f6907498858d6b0ef (patch) | |
tree | 22803d7496f4bab3ca061c3ba6ff99da0f0c427b /firmware | |
parent | 3a1870160e12ccb0250fa2b56b2867aa9c02cfe8 (diff) | |
download | vboot-302794156d6689d97eba7d7f6907498858d6b0ef.tar.gz |
vboot/ui: Check allocated pointer before using the pointerstabilize-14149.B
Change the order of checking whether the allocated pointer is null
and memset the allocated pointer. Prevent using a null pointer, which
may cause segmentation fault.
BUG=none
TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 \
make -j32 test_setup && make -j32 runtests;
TEST=emerge-asurada depthcharge
BRANCH=none
Signed-off-by: edisonhello <edisonhello@google.com>
Change-Id: I5fc91b5157b32b6b7263d580998eceb6efe9a63a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3077962
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/2lib/2ui.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c index fa78792a..9b8a9225 100644 --- a/firmware/2lib/2ui.c +++ b/firmware/2lib/2ui.c @@ -268,11 +268,11 @@ vb2_error_t vb2_ui_screen_change(struct vb2_ui_context *ui, enum vb2_screen id) } else { /* Allocate the requested screen on top of the stack. */ cur_state = malloc(sizeof(*ui->state)); - memset(cur_state, 0, sizeof(*ui->state)); if (cur_state == NULL) { VB2_DEBUG("WARNING: malloc failed; ignoring\n"); return VB2_REQUEST_UI_CONTINUE; } + memset(cur_state, 0, sizeof(*ui->state)); cur_state->prev = ui->state; cur_state->screen = new_screen_info; ui->state = cur_state; |