Commit 796ad622 authored by Guopeng Zhang's avatar Guopeng Zhang Committed by Tejun Heo
Browse files

cgroup/dmem: Return -ENOMEM on failed pool preallocation



get_cg_pool_unlocked() handles allocation failures under dmemcg_lock by
dropping the lock, preallocating a pool with GFP_KERNEL, and retrying the
locked lookup and creation path.

If the fallback allocation fails too, pool remains NULL. Since the loop
condition is while (!pool), the function can keep retrying instead of
propagating the allocation failure to the caller.

Set pool to ERR_PTR(-ENOMEM) when the fallback allocation fails so the
loop exits through the existing common return path. The callers already
handle ERR_PTR() from get_cg_pool_unlocked(), so this restores the
expected error path.

Fixes: b168ed45 ("kernel/cgroup: Add "dmem" memory accounting cgroup")
Cc: stable@vger.kernel.org # v6.14+
Signed-off-by: default avatarGuopeng Zhang <zhangguopeng@kylinos.cn>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent dde2f938
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -602,6 +602,7 @@ get_cg_pool_unlocked(struct dmemcg_state *cg, struct dmem_cgroup_region *region)
				pool = NULL;
				continue;
			}
			pool = ERR_PTR(-ENOMEM);
		}
	}