[PATCH] lib: fwts_uefi: only close fp if it was successfully opened

IvanHu ivan.hu at canonical.com
Thu May 16 03:30:28 UTC 2013


On 05/07/2013 07:25 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997293, Dereference after null check (FORWARD_NULL)
>
> Coverity caught a bug where we are closing fp even if it failed
> to open.  Close it only if it opens correctly and fp is not NULL.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_uefi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
> index 29cad80..f8678ab 100644
> --- a/src/lib/src/fwts_uefi.c
> +++ b/src/lib/src/fwts_uefi.c
> @@ -107,8 +107,8 @@ static int fwts_uefi_get_interface(char **path)
>   					strcpy(efivar_path, "/sys/firmware/efi/vars");
>   			}
>   		}
> +		fclose(fp);
>   	}
> -	fclose(fp);
>
>   	*path = NULL;
>
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list