mm: vmpressure: don't need call kfree if kstrndup fails
authorYang Shi <yang.shi@linux.alibaba.com>
Thu, 2 Apr 2020 04:09:59 +0000 (21:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Apr 2020 16:35:31 +0000 (09:35 -0700)
When kstrndup fails, no memory was allocated and we can exit directly.

[david@redhat.com: reword changelog]
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Acked-by: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/vmpressure.c

index 4bac22fe1aa214c32bba6f7d5f46f82b5ea208ba..0590f00334489306b90e7b4e7507981eacedf2c5 100644 (file)
@@ -371,10 +371,8 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
        int ret = 0;
 
        spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL);
-       if (!spec) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!spec)
+               return -ENOMEM;
 
        /* Find required level */
        token = strsep(&spec, ",");