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 <keescook@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
This commit is contained in:
parent
47e0bbb7fa
commit
be4a1326d1
|
@ -54,10 +54,9 @@ static ssize_t trigger_request_store(struct device *dev,
|
||||||
int rc;
|
int rc;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = kzalloc(count + 1, GFP_KERNEL);
|
name = kstrndup(buf, count, GFP_KERNEL);
|
||||||
if (!name)
|
if (!name)
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
memcpy(name, buf, count);
|
|
||||||
|
|
||||||
pr_info("loading '%s'\n", name);
|
pr_info("loading '%s'\n", name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue