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:
parent
199311e6a5
commit
b0d13ba557
@ -332,6 +332,7 @@ static int calc_evm_hash(const char *file, unsigned char *hash)
|
|||||||
}
|
}
|
||||||
if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
|
if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
|
||||||
log_err("ioctl() failed\n");
|
log_err("ioctl() failed\n");
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
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)) {
|
if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
|
||||||
log_err("ioctl() failed\n");
|
log_err("ioctl() failed\n");
|
||||||
|
close(fd);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user