Skip to content

Commit d62ff36

Browse files
andy-shevtorvalds
authored andcommitted
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]>
1 parent bf8d5d5 commit d62ff36

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

mm/vmpressure.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,11 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
390390
char *token;
391391
int ret = 0;
392392

393-
spec_orig = spec = kzalloc(MAX_VMPRESSURE_ARGS_LEN + 1, GFP_KERNEL);
393+
spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL);
394394
if (!spec) {
395395
ret = -ENOMEM;
396396
goto out;
397397
}
398-
strncpy(spec, args, MAX_VMPRESSURE_ARGS_LEN);
399398

400399
/* Find required level */
401400
token = strsep(&spec, ",");

0 commit comments

Comments
 (0)