__return_syscall: check input & fix unmap memory in error cases
Change-Id: I5de3ab3acd46770518b79bdc6f1c2e00c1cd5096
This commit is contained in:
committed by
Masamichi Takagi
parent
924ba7fd65
commit
45bc6a617a
@@ -1841,14 +1841,23 @@ void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet,
|
|||||||
unsigned long phys;
|
unsigned long phys;
|
||||||
struct syscall_response *res;
|
struct syscall_response *res;
|
||||||
|
|
||||||
|
if (!os || ihk_host_validate_os(os) || !packet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
phys = ihk_device_map_memory(ihk_os_to_dev(os),
|
phys = ihk_device_map_memory(ihk_os_to_dev(os),
|
||||||
packet->resp_pa, sizeof(*res));
|
packet->resp_pa, sizeof(*res));
|
||||||
|
if (!phys) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
res = ihk_device_map_virtual(ihk_os_to_dev(os),
|
res = ihk_device_map_virtual(ihk_os_to_dev(os),
|
||||||
phys, sizeof(*res), NULL, 0);
|
phys, sizeof(*res), NULL, 0);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
printk("%s: ERROR: invalid response structure address\n",
|
printk("%s: ERROR: invalid response structure address\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
|
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, sizeof(*res));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user