linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails
@ 2020-02-11  5:24 Yang Shi
  2020-02-11  5:24 ` [PATCH 2/2] mm: vmpressure: use mem_cgroup_is_root API Yang Shi
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Yang Shi @ 2020-02-11  5:24 UTC (permalink / raw)
  To: akpm; +Cc: yang.shi, linux-mm, linux-kernel

When kstrndup fails (returns NULL) there is no memory is allocated by
kmalloc, so no need to call kfree().

Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
 mm/vmpressure.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 4bac22f..0590f00 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -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, ",");
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-02-13  4:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11  5:24 [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails Yang Shi
2020-02-11  5:24 ` [PATCH 2/2] mm: vmpressure: use mem_cgroup_is_root API Yang Shi
2020-02-12  2:08   ` David Rientjes
2020-02-12  8:23   ` Michal Hocko
2020-02-13  3:18     ` Yang Shi
2020-02-12 11:19   ` David Hildenbrand
2020-02-12  2:07 ` [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails David Rientjes
2020-02-12 11:21 ` David Hildenbrand
2020-02-13  3:14   ` Yang Shi
2020-02-13  4:48     ` Andrew Morton
2020-02-13  4:51       ` Yang Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).