diff options
| author | Peter Jones <pjones@redhat.com> | 2013-11-15 09:38:41 -0500 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2013-11-21 11:48:24 -0500 |
| commit | 3a7feeff6cdb3b96a1ef2ccff8c150e2324d50a9 (patch) | |
| tree | e0ec662779e85ad42b64fb08cc5e4cfe02895904 | |
| parent | 4dbef508ab6359e8ca14df53b83f970bdeec17ba (diff) | |
| download | efi-boot-shim-3a7feeff6cdb3b96a1ef2ccff8c150e2324d50a9.tar.gz efi-boot-shim-3a7feeff6cdb3b96a1ef2ccff8c150e2324d50a9.zip | |
Rewrite directory traversal allocation path so coverity can grok it.
The things we do for our tools. In this case, make the AllocatePool()
happen outside of a conditional, even though that conditional will
always bee satisfied. This way coverity won't think we're setting fi
to NULL and passing it to StrCaseCmp.
Signed-off-by: Peter Jones <pjones@redhat.com>
| -rw-r--r-- | fallback.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -445,25 +445,32 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname) return EFI_SUCCESS; } FreePool(buffer); + buffer = NULL; bs = 0; do { bs = 0; rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, NULL); - if (rc == EFI_BUFFER_TOO_SMALL) { - buffer = AllocateZeroPool(bs); - if (!buffer) { - Print(L"Could not allocate memory\n"); - return EFI_OUT_OF_RESOURCES; - } + if (EFI_ERROR(rc) && rc != EFI_BUFFER_TOO_SMALL) { + Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc); + if (buffer) + FreePool(buffer); + return rc; + } - rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer); + buffer = AllocateZeroPool(bs); + if (!buffer) { + Print(L"Could not allocate memory\n"); + return EFI_OUT_OF_RESOURCES; } + + rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer); if (EFI_ERROR(rc)) { Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc); FreePool(buffer); return rc; } + if (bs == 0) break; |
