summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2022-05-18 17:11:55 -0400
committerPeter Jones <pjones@redhat.com>2022-05-23 16:49:53 -0400
commit1eca363afe1e48f5aa1ee3c70f2042e9c511692e (patch)
treef15d1a612722b2f55a4d486f655230b7ad88170a
parent0214cd9cef5aaa9b719d4b2b12d58b32f174edf7 (diff)
downloadefi-boot-shim-1eca363afe1e48f5aa1ee3c70f2042e9c511692e.tar.gz
efi-boot-shim-1eca363afe1e48f5aa1ee3c70f2042e9c511692e.zip
mok import: handle OOM case
Coverity pointed out that AllocateZeroPool() can error, and then we immediately dereference the NULL. This handles the error case. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--mok.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mok.c b/mok.c
index d1e51d0f..63ddfcaa 100644
--- a/mok.c
+++ b/mok.c
@@ -871,6 +871,10 @@ EFI_STATUS import_one_mok_state(struct mok_state_variable *v,
if (efi_status == EFI_NOT_FOUND &&
v->flags & MOK_VARIABLE_INVERSE) {
v->data = AllocateZeroPool(4);
+ if (!v->data) {
+ perror(L"Out of memory\n");
+ return EFI_OUT_OF_RESOURCES;
+ }
v->data[0] = 0x01;
v->data_size = 1;
} else if (efi_status == EFI_NOT_FOUND) {