* [PATCH] mm/list_lru: Remove redundant NULL check before kfree()
@ 2025-02-28 14:18 Yu-Chun Lin
2025-02-28 16:39 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Yu-Chun Lin @ 2025-02-28 14:18 UTC (permalink / raw)
To: akpm
Cc: linux-mm, linux-kernel, jserv, visitorckw, Yu-Chun Lin,
kernel test robot
The kernel's kfree() documentation states: "If @object is NULL, no
operation is performed." Remove checking for NULL before calling kfree().
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502250720.9ueIb7Xh-lkp@intel.com/
Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
---
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.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/list_lru: Remove redundant NULL check before kfree()
2025-02-28 14:18 [PATCH] mm/list_lru: Remove redundant NULL check before kfree() Yu-Chun Lin
@ 2025-02-28 16:39 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2025-02-28 16:39 UTC (permalink / raw)
To: Yu-Chun Lin, akpm
Cc: linux-mm, linux-kernel, jserv, visitorckw, kernel test robot
On 2/28/25 15:18, Yu-Chun Lin wrote:
> The kernel's kfree() documentation states: "If @object is NULL, no
> operation is performed." Remove checking for NULL before calling kfree().
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202502250720.9ueIb7Xh-lkp@intel.com/
> Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
This is already in mm-unstable:
https://lore.kernel.org/all/20250227082223.1173847-1-jingxiangzeng.cas@gmail.com/
> ---
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-28 16:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-28 14:18 [PATCH] mm/list_lru: Remove redundant NULL check before kfree() Yu-Chun Lin
2025-02-28 16:39 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox