tpm_pcr_read: close file when returning early

When return from inside the for() loop, the open file was not
closed.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
Patrick Ohly 2015-08-13 18:21:53 +02:00 committed by Dmitry Kasatkin
parent fa0b30b15e
commit 453d3db8a5

View File

@ -1143,6 +1143,7 @@ static int tpm_pcr_read(int idx, uint8_t *pcr, int len)
{
FILE *fp;
char *p, pcr_str[7], buf[70]; /* length of the TPM string */
int result = -1;
sprintf(pcr_str, "PCR-%d", idx);
@ -1158,11 +1159,12 @@ static int tpm_pcr_read(int idx, uint8_t *pcr, int len)
break;
if (!strncmp(p, pcr_str, 6)) {
hex2bin(pcr, p + 7, len);
return 0;
result = 0;
break;
}
}
fclose(fp);
return -1;
return result;
}
#define TCG_EVENT_NAME_LEN_MAX 255