[PATCH] mm/list_lru: Remove unnecessary NULL check before kfree()
From: xiaopeitux
Date: Thu Feb 27 2025 - 01:16:40 EST
From: Pei Xiao <xiaopei01@xxxxxxxxxx>
Since kfree() already checks if its argument is NULL, an additional
check before calling kfree() is unnecessary and can be removed.
Remove it and thus also the following cocci warning:
WARNING: NULL check before some freeing functions is not needed.
Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
---
mm/list_lru.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 7d69434c70e0..7c8fb17d9027 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -548,8 +548,7 @@ int memcg_list_lru_alloc(struct mem_cgroup *memcg, struct list_lru *lru,
}
xas_unlock_irqrestore(&xas, flags);
} while (xas_nomem(&xas, gfp));
- if (mlru)
- kfree(mlru);
+ kfree(mlru);
} while (pos != memcg && !css_is_dying(&pos->css));
return xas_error(&xas);
--
2.25.1