diff mbox series

mm/list_lru: Remove unnecessary NULL check before kfree()

Message ID tencent_0B119ADC0E546990F05E3727AB7364AEAB08@qq.com (mailing list archive)
State New
Headers show
Series mm/list_lru: Remove unnecessary NULL check before kfree() | expand

Commit Message

xiaopeitux@foxmail.com Feb. 27, 2025, 6:10 a.m. UTC
From: Pei Xiao <xiaopei01@kylinos.cn>

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@kylinos.cn>
---
 mm/list_lru.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

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);