[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1448371608-18053-5-git-send-email-m@bjorling.me>
Date: Tue, 24 Nov 2015 14:26:47 +0100
From: Matias Bjørling <m@...rling.me>
To: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
axboe@...com
Cc: hch@...radead.org, keith.busch@...el.com,
sudipm.mukherjee@...il.com, ww.tao0320@...il.com,
Sudip Mukherjee <sudip@...torindia.org>,
Matias Bjørling <m@...rling.me>
Subject: [PATCH 4/5] lightnvm: fix ioctl memory leaks
From: Sudip Mukherjee <sudipm.mukherjee@...il.com>
If copy_to_user() fails we returned error but we missed releasing
devices.
Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>
Signed-off-by: Matias Bjørling <m@...rling.me>
---
drivers/lightnvm/core.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 5178645..ea50fa5 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -680,8 +680,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
info->tgtsize = tgt_iter;
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;
+ }
kfree(info);
return 0;
@@ -724,8 +726,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
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;
+ }
kfree(devices);
return 0;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists