ACK: [PATCH] uefirtvariable: fix memory leak
Colin Ian King
colin.king at canonical.com
Fri May 14 08:13:54 UTC 2021
On 14/05/2021 09:07, Colin Ian King wrote:
> On 14/05/2021 09:00, Ivan Hu wrote:
>> Also add void for the ioctl which is intentional ignore return for
>> deleting variable.
>>
>> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
>> ---
>> src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
>> index b756ac96..f5aaa5fb 100644
>> --- a/src/uefi/uefirtvariable/uefirtvariable.c
>> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
>> @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw)
>> /* delete the variable which was set */
>> setvariable.DataSize = 0;
>> status = ~0ULL;
>> - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
>> + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
>>
>> variablename = malloc(sizeof(uint16_t) * variablenamesize);
>> if (!variablename) {
>> @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw)
>> } else
>> fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test.");
>>
>> + if (variablename)
>> + free(variablename);
Actually free of a NULL variablename is OK,so the if () is not strictly
required, but lets leave that in as it shows intent.
>> +
>> return FWTS_OK;
>> }
>>
>>
>
> Thanks Ivan.
>
> Acked-by: Colin Ian King <colin.king at canonical.com>
>
More information about the fwts-devel
mailing list