uti: Add error checks to kmalloc of struct uti_attr

This commit is contained in:
Masamichi Takagi
2018-07-30 10:24:07 +09:00
parent 781a69617b
commit fca02ee248

View File

@@ -2641,9 +2641,13 @@ retry_tid:
if (old->mod_clone_arg) { if (old->mod_clone_arg) {
new->mod_clone_arg = kmalloc(sizeof(struct uti_attr), new->mod_clone_arg = kmalloc(sizeof(struct uti_attr),
IHK_MC_AP_NOWAIT); IHK_MC_AP_NOWAIT);
if (new->mod_clone_arg) if (!new->mod_clone_arg) {
memcpy(new->mod_clone_arg, old->mod_clone_arg, kprintf("%s: error: allocating mod_clone_arg\n",
sizeof(struct uti_attr)); __func__);
return -ENOMEM;
}
memcpy(new->mod_clone_arg, old->mod_clone_arg,
sizeof(struct uti_attr));
} }
} }
chain_thread(new); chain_thread(new);
@@ -9239,7 +9243,11 @@ SYSCALL_DECLARE(util_indicate_clone)
mod != SPAWN_TO_REMOTE) mod != SPAWN_TO_REMOTE)
return -EINVAL; return -EINVAL;
if (arg) { if (arg) {
kattr = kmalloc(sizeof(struct uti_attr), IHK_MC_AP_NOWAIT); if (!(kattr = kmalloc(sizeof(struct uti_attr), IHK_MC_AP_NOWAIT))) {
kprintf("%s: error: allocating kattr\n", __func__);
return -ENOMEM;
}
if (copy_from_user(kattr, arg, sizeof(struct uti_attr))) { if (copy_from_user(kattr, arg, sizeof(struct uti_attr))) {
kfree(kattr); kfree(kattr);
return -EFAULT; return -EFAULT;