Thread (14 messages) 14 messages, 4 authors, 2016-01-07

[PATCH v2 2/5] test: firmware_class: use kstrndup() where appropriate

flat view
STALE3933d

From: Brian Norris <computersforpeace@gmail.com>
Date: 2015-12-09 22:50:59
Also in: lkml
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

We're essentially just doing an open-coded kstrndup(). The only
differences are with what happens after the first '\0' character, but
request_firmware() doesn't care about that.

Suggested-by: Kees Cook <redacted>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
New in v2

 lib/test_firmware.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 841191061816..690b9c35a274 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -54,10 +54,9 @@ static ssize_t trigger_request_store(struct device *dev,
 	int rc;
 	char *name;
 
-	name = kzalloc(count + 1, GFP_KERNEL);
+	name = kstrndup(buf, count, GFP_KERNEL);
 	if (!name)
 		return -ENOSPC;
-	memcpy(name, buf, count);
 
 	pr_info("loading '%s'\n", name);
 
-- 
2.6.0.rc2.230.g3dd15c0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help