lkml.org 
[lkml]   [2020]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails
Date
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
\
 
 \ /
  Last update: 2020-02-11 06:25    [W:0.135 / U:6.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site