Commit 76e25081 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Jens Axboe

lightnvm: fix ioctl memory leaks

If copy_to_user() fails we returned error but we missed releasing
devices.
Signed-off-by: default avatarSudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 8261bd48
...@@ -680,8 +680,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg) ...@@ -680,8 +680,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
info->tgtsize = tgt_iter; info->tgtsize = tgt_iter;
up_write(&nvm_lock); up_write(&nvm_lock);
if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) {
kfree(info);
return -EFAULT; return -EFAULT;
}
kfree(info); kfree(info);
return 0; return 0;
...@@ -724,8 +726,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg) ...@@ -724,8 +726,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
devices->nr_devices = i; devices->nr_devices = i;
if (copy_to_user(arg, devices, sizeof(struct nvm_ioctl_get_devices))) if (copy_to_user(arg, devices,
sizeof(struct nvm_ioctl_get_devices))) {
kfree(devices);
return -EFAULT; return -EFAULT;
}
kfree(devices); kfree(devices);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment