diff mbox series

efi_loader: cleanup for tee backed variables

Message ID 20200701134125.482509-1-ilias.apalodimas@linaro.org
State Accepted, archived
Commit ecb833a0c623172cf72e1c6dda9e6362c30d5a86
Delegated to: Heinrich Schuchardt
Headers show
Series efi_loader: cleanup for tee backed variables | expand

Commit Message

Ilias Apalodimas July 1, 2020, 1:41 p.m. UTC
There's 2 variables in efi_get_next_variable_name() checking the size of
the variable name. Let's get rid of the reduntant definition and
simplitfy the code a bit.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_variable_tee.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Heinrich Schuchardt July 7, 2020, 8:36 p.m. UTC | #1
On 01.07.20 15:41, Ilias Apalodimas wrote:
> There's 2 variables in efi_get_next_variable_name() checking the size of
> the variable name. Let's get rid of the reduntant definition and
> simplitfy the code a bit.
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index cacc76e23db1..1d127720cd2f 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -351,7 +351,6 @@  efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
 	efi_uintn_t out_name_size;
 	efi_uintn_t in_name_size;
 	efi_uintn_t tmp_dsize;
-	efi_uintn_t name_size;
 	u8 *comm_buf = NULL;
 	efi_status_t ret;
 
@@ -370,19 +369,18 @@  efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
 		goto out;
 	}
 
-	name_size = u16_strsize(variable_name);
-	if (name_size > max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) {
+	if (in_name_size > max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) {
 		ret = EFI_INVALID_PARAMETER;
 		goto out;
 	}
 
 	/* Trim output buffer size */
 	tmp_dsize = *variable_name_size;
-	if (name_size + tmp_dsize >
+	if (in_name_size + tmp_dsize >
 			max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) {
 		tmp_dsize = max_payload_size -
 				MM_VARIABLE_GET_NEXT_HEADER_SIZE -
-				name_size;
+				in_name_size;
 	}
 
 	payload_size = MM_VARIABLE_GET_NEXT_HEADER_SIZE + out_name_size;