[PATCH 1/1] drivers/mtd/devices/phram.c: replace kmalloc/strcpy by kstrdup

Fabian Frederick fabf at skynet.be
Wed May 28 13:31:28 PDT 2014


Cc: Joern Engel <joern at lazybastard.org>
Cc: Brian Norris <computersforpeace at gmail.com>
Signed-off-by: Fabian Frederick <fabf at skynet.be>
---
 drivers/mtd/devices/phram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 2cceebf..3bac7da 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -181,12 +181,10 @@ static int parse_name(char **pname, const char *token)
 	if (len > 64)
 		return -ENOSPC;
 
-	name = kmalloc(len, GFP_KERNEL);
+	name = kstrdup(token, GFP_KERNEL);
 	if (!name)
 		return -ENOMEM;
 
-	strcpy(name, token);
-
 	*pname = name;
 	return 0;
 }
-- 
1.9.1



More information about the linux-mtd mailing list