diff options
author | Andy Shevchenko <[email protected]> | 2018-06-07 17:07:50 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2018-06-07 17:34:36 -0700 |
commit | d62ff365b812ecd7415252568c1836811b3dde02 (patch) | |
tree | 1ea4e12f13469cf607bdd46a8686d39ad423b319 | |
parent | bf8d5d52ffe89aac5b46ddb39dd1a4351fae5df4 (diff) |
mm/vmpressure.c: use kstrndup instead of kmalloc+strncpy
Using kstrndup() simplifies the code.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/vmpressure.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 85350ce2d25d..7142207224d3 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -390,12 +390,11 @@ int vmpressure_register_event(struct mem_cgroup *memcg, char *token; int ret = 0; - spec_orig = spec = kzalloc(MAX_VMPRESSURE_ARGS_LEN + 1, GFP_KERNEL); + spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL); if (!spec) { ret = -ENOMEM; goto out; } - strncpy(spec, args, MAX_VMPRESSURE_ARGS_LEN); /* Find required level */ token = strsep(&spec, ","); |