Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275231

[PATCH] lightnvm: fix memory leak

From Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] lightnvm: fix memory leak
Date 2015-11-23 11:40 +0100
Message-ID <qxWHo-x4-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] lightnvm: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-23 11:40 +0100
  Re: [PATCH] lightnvm: fix memory leak Matias Bjørling <mb@lightnvm.io> - 2015-11-23 16:20 +0100
    Re: [PATCH] lightnvm: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-23 17:50 +0100
      Re: [PATCH] lightnvm: fix memory leak Matias <mb@lightnvm.io> - 2015-11-23 19:50 +0100

csiph-web