From b427a3431ee27460dafc7e33e4cbe49de3baf4d7 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 12 Mar 2025 14:11:03 -0400 Subject: mirror_mok_db(): get rid of an unused variable+allocation Coverity identified a resource leak of namen8 in mirror_mok_db(), and upon further examination nothing is even using it any more; we're allocating it and populating it for nothing. This removes all that. Resolves: Coverity CID 457510 Signed-off-by: Peter Jones --- mok.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'mok.c') diff --git a/mok.c b/mok.c index 8367fad5..20f86b06 100644 --- a/mok.c +++ b/mok.c @@ -578,7 +578,7 @@ mirror_one_esl(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, } static EFI_STATUS -mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, +mirror_mok_db(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, UINT8 *FullData, SIZE_T FullDataSize, BOOLEAN only_first) { EFI_STATUS efi_status = EFI_SUCCESS; @@ -605,14 +605,12 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, } CHAR16 *namen; - CHAR8 *namen8; UINTN namelen, namesz; namelen = StrLen(name); namesz = namelen * 2; if (only_first) { namen = name; - namen8 = name8; } else { namelen += 18; namesz += 34; @@ -621,12 +619,6 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, LogError(L"Could not allocate %lu bytes", namesz); return EFI_OUT_OF_RESOURCES; } - namen8 = AllocateZeroPool(namelen); - if (!namen8) { - FreePool(namen); - LogError(L"Could not allocate %lu bytes", namelen); - return EFI_OUT_OF_RESOURCES; - } } UINTN pos, i; @@ -668,11 +660,6 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, if (!only_first) { SPrint(namen, namelen, L"%s%lu", name, i); namen[namelen-1] = 0; - /* uggggh */ - UINTN j; - for (j = 0; j < namelen; j++) - namen8[j] = (CHAR8)(namen[j] & 0xff); - namen8[namelen - 1] = 0; } /* @@ -685,7 +672,6 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, efi_status); if (!only_first) { FreePool(namen); - FreePool(namen8); } return efi_status; } @@ -1039,7 +1025,7 @@ mirror_one_mok_variable(struct mok_state_variable *v, !(v->flags & MOK_VARIABLE_CONFIG_ONLY)) { dprint(L"calling mirror_mok_db(\"%s\", datasz=%lu)\n", v->rtname, FullDataSize); - efi_status = mirror_mok_db(v->rtname, (CHAR8 *)v->rtname8, v->guid, + efi_status = mirror_mok_db(v->rtname, v->guid, attrs, FullData, FullDataSize, only_first); dprint(L"mirror_mok_db(\"%s\", datasz=%lu) returned %r\n", -- cgit v1.2.3