__return_syscall: check input & fix unmap memory in error cases

Change-Id: I5de3ab3acd46770518b79bdc6f1c2e00c1cd5096
This commit is contained in:
tinhnt86
2020-10-08 19:24:53 +07:00
committed by Masamichi Takagi
parent 924ba7fd65
commit 45bc6a617a

View File

@ -1841,14 +1841,23 @@ void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet,
unsigned long phys;
struct syscall_response *res;
if (!os || ihk_host_validate_os(os) || !packet) {
return;
}
phys = ihk_device_map_memory(ihk_os_to_dev(os),
packet->resp_pa, sizeof(*res));
if (!phys) {
return;
}
res = ihk_device_map_virtual(ihk_os_to_dev(os),
phys, sizeof(*res), NULL, 0);
if (!res) {
printk("%s: ERROR: invalid response structure address\n",
__FUNCTION__);
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, sizeof(*res));
return;
}