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

Colin King colin.king at canonical.com
Mon May 6 23:25:08 UTC 2013


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;
 
-- 
1.8.1.2




More information about the fwts-devel mailing list