diff options
author | Brian Norris <computersforpeace@gmail.com> | 2015-12-09 17:50:26 -0500 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2016-01-07 15:43:28 -0500 |
commit | be4a1326d12cce8df1f57017bf4112eaab437a38 (patch) | |
tree | c271e4c6942f46a387efabcdf3d003c9a80b5084 | |
parent | 47e0bbb7fa985a0f1b5794a8653fae4f8f49de77 (diff) |
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>
-rw-r--r-- | lib/test_firmware.c | 3 |
1 files changed, 1 insertions, 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, | |||
54 | int rc; | 54 | int rc; |
55 | char *name; | 55 | char *name; |
56 | 56 | ||
57 | name = kzalloc(count + 1, GFP_KERNEL); | 57 | name = kstrndup(buf, count, GFP_KERNEL); |
58 | if (!name) | 58 | if (!name) |
59 | return -ENOSPC; | 59 | return -ENOSPC; |
60 | memcpy(name, buf, count); | ||
61 | 60 | ||
62 | pr_info("loading '%s'\n", name); | 61 | pr_info("loading '%s'\n", name); |
63 | 62 | ||