calc_evm_hmac/hash: avoid fd leak when ioctl fails

When opening the file succeeds but ioctl() then fails, the file must
be closed before returning.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
Patrick Ohly 2015-09-09 23:02:01 +03:00 committed by Dmitry Kasatkin
parent 199311e6a5
commit b0d13ba557

View File

@ -332,6 +332,7 @@ static int calc_evm_hash(const char *file, unsigned char *hash)
}
if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
log_err("ioctl() failed\n");
close(fd);
return -1;
}
close(fd);
@ -885,6 +886,7 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
}
if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
log_err("ioctl() failed\n");
close(fd);
goto out;
}
close(fd);