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 <firstname.lastname@example.org>
Signed-off-by: Andrew Morton <email@example.com>
Acked-by: Giuseppe Scrivano <firstname.lastname@example.org>
Acked-by: Tejun Heo <email@example.com>
Cc: Mike Kravetz <firstname.lastname@example.org>
Cc: David Rientjes <email@example.com>
Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
1 file changed