Re: [PATCH] selftests/cgroup: check malloc return value in alloc_anon functions
From: Muchun Song
Date: Sun May 10 2026 - 22:47:36 EST
> On May 11, 2026, at 10:16, Hongfu Li <lihongfu@xxxxxxxxxx> wrote:
>
> The alloc_anon() function calls malloc() without checking for a NULL
> return. If memory allocation fails, a NULL pointer dereference will
> occur when accessing the buffer.
>
> Add proper error handling to return -1 when malloc() fails in all
> four alloc_anon variants:
> - alloc_anon()
> - alloc_anon_50M_check()
> - alloc_anon_noexit()
> - alloc_anon_50M_check_swap()
>
> Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
Reviewed-by: Muchun Song <muchun.song@xxxxxxxxx>
Thanks.