All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/5] lightnvm: fix memory leak
@ 2015-11-24 10:34 Sudip Mukherjee
  2015-11-24 10:34 ` [PATCH v2 2/5] lightnvm: check for max sector Sudip Mukherjee
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Sudip Mukherjee @ 2015-11-24 10:34 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: linux-kernel, Sudip Mukherjee

If copy_to_user() fails we returned error but we missed releasing
devices.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v1 on fixed one error. v2 fixes both.

 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 f659e60..e338048 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -677,8 +677,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;
@@ -721,8 +723,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;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-11-24 11:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 10:34 [PATCH v2 1/5] lightnvm: fix memory leak Sudip Mukherjee
2015-11-24 10:34 ` [PATCH v2 2/5] lightnvm: check for max sector Sudip Mukherjee
2015-11-24 11:00   ` Matias Bjørling
2015-11-24 10:34 ` [PATCH v2 3/5] lightnvm: create dma pool first Sudip Mukherjee
2015-11-24 11:01   ` Matias Bjørling
2015-11-24 10:34 ` [PATCH v2 4/5] lightnvm: release dev if dma pools fails Sudip Mukherjee
2015-11-24 11:06   ` Matias Bjørling
2015-11-24 10:35 ` [PATCH v2 5/5] lightnvm: return error if manager not found Sudip Mukherjee
2015-11-24 11:10   ` Matias Bjørling
2015-11-24 10:57 ` [PATCH v2 1/5] lightnvm: fix memory leak Matias Bjørling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.