Re: [PATCH] mm: memcg: initialize *locked in memcg1_oom_prepare() stub
From: Joshua Hahn
Date: Fri Jun 26 2026 - 09:56:38 EST
Hi Breno, I hope you are doing well : -)
Woah, thank you for finding and fixing this bug!
> Fixes: e93d4166b40a ("mm: memcg: put cgroup v1-specific code under a config option")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
> mm/memcontrol-v1.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
> index f92f81108d5ed..4fa6e2bc8413f 100644
> --- a/mm/memcontrol-v1.h
> +++ b/mm/memcontrol-v1.h
> @@ -107,7 +107,11 @@ static inline void memcg1_remove_from_trees(struct mem_cgroup *memcg) {}
> static inline void memcg1_soft_limit_reset(struct mem_cgroup *memcg) {}
> static inline void memcg1_css_offline(struct mem_cgroup *memcg) {}
>
> -static inline bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked) { return true; }
> +static inline bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked)
> +{
> + *locked = false;
> + return true;
> +}
> static inline void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked) {}
> static inline void memcg1_oom_recover(struct mem_cgroup *memcg) {}
Part of me wonders if we should just initialize locked = false in the
caller (mem_cgroup_oom) as to not make the stub have side effects,
but your chnage looks correct and this is a fix so perhaps that is
not so important.
Looks good to me! Thank you again Breno : -)
Reviewed-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>