From: Brian Norris Date: Wed, 9 Dec 2015 22:50:26 +0000 (-0800) Subject: test: firmware_class: use kstrndup() where appropriate X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=be4a1326d12cce8df1f57017bf4112eaab437a38;p=linux-beck.git test: firmware_class: use kstrndup() where appropriate 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 Signed-off-by: Brian Norris Signed-off-by: Shuah Khan --- 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);