public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: fix memory leak
@ 2015-11-23 10:35 Sudip Mukherjee
  2015-11-23 15:13 ` Matias Bjørling
  0 siblings, 1 reply; 4+ messages in thread
From: Sudip Mukherjee @ 2015-11-23 10:35 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>
---
 drivers/lightnvm/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index f659e60..6688b60 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -721,8 +721,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] 4+ messages in thread

end of thread, other threads:[~2015-11-23 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 10:35 [PATCH] lightnvm: fix memory leak Sudip Mukherjee
2015-11-23 15:13 ` Matias Bjørling
2015-11-23 16:40   ` Sudip Mukherjee
2015-11-23 18:41     ` Matias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox