[PATCH] uefirtvariable: fix the unchecked return value
IvanHu
ivan.hu at canonical.com
Wed May 8 08:15:49 UTC 2013
On 05/08/2013 03:07 PM, Colin Ian King wrote:
> On 08/05/13 04:06, Ivan Hu wrote:
>> Coverity CID #997310: Unchecked return value
>>
>> Need to check the return value for calling function "ioctl".
>>
>> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
>> ---
>> src/uefi/uefirtvariable/uefirtvariable.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
>> index 16cd240..7c2fc1f 100644
>> --- a/src/uefi/uefirtvariable/uefirtvariable.c
>> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
>> @@ -858,6 +858,7 @@ static int setvariable_invalidattr(
>> EFI_GUID *gtestguid,
>> const uint8_t datadiff)
>> {
>> + long ioret;
>> struct efi_setvariable setvariable;
>> uint64_t status;
>> uint64_t dataindex;
>> @@ -873,9 +874,9 @@ static int setvariable_invalidattr(
>> setvariable.Data = data;
>> setvariable.status = &status;
>>
>> - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
>> + ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
>>
>> - if (status == EFI_SUCCESS) {
>> + if ((status == EFI_SUCCESS) && (ioret != -1)) {
>> fwts_warning(fw,
>> "After ExitBootServices() is performed, the "
>> "attributes %" PRIu32 ", "
>>
> No entirely sure about this. What about the case when ioret == -1, is
> this an error/failure? In other tests this is reported as a failure,
> where as in this case it seems to be silently ignored.
>
> Colin
>
>
>
In this test case, we do the setvariable with the invalid attributes.
We expects the firmware return a fail for the setvariable, ioret == -1.
If not, will give an warnings.
Ivan
More information about the fwts-devel
mailing list