hugetlb_cgroup: fix illegal access to memory
This appears to be a mistake in commit faced7e0806cf ("mm: hugetlb
controller for cgroups v2").
Essentially that commit does a hugetlb_cgroup_from_counter assuming that
page_counter_try_charge has initialized counter.
But if that has failed then it seems will not initialize counter, so
hugetlb_cgroup_from_counter(counter) ends up pointing to random memory,
causing kasan to complain.
The solution is to simply use 'h_cg', instead of
hugetlb_cgroup_from_counter(counter), since that is a reference to the
hugetlb_cgroup anyway. After this change kasan ceases to complain.
Fixes: faced7e0806cf ("mm: hugetlb controller for cgroups v2")
Signed-off-by: Mina Almasry <email@example.com>
Signed-off-by: Andrew Morton <firstname.lastname@example.org>
Acked-by: Giuseppe Scrivano <email@example.com>
Acked-by: Tejun Heo <firstname.lastname@example.org>
Cc: Mike Kravetz <email@example.com>
Cc: David Rientjes <firstname.lastname@example.org>
Signed-off-by: Linus Torvalds <email@example.com>
1 file changed