mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
authorSeongJae Park <sj@kernel.org>
Mon, 6 Nov 2023 23:34:07 +0000 (23:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:19:58 +0000 (17:19 +0000)
commit76801f32d963e5854ea69fb9821d2d86b62790b9
tree057cbc25abd3af28a0220daaff796ce40bc46fb1
parent0bf5055d5d33133c3a7cc5e4032eeb0ba7832c44
mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure

commit 84055688b6bc075c92a88e2d6c3ad26ab93919f9 upstream.

DAMOS tried regions sysfs directory allocation function
(damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation
failure.  In the case, the code will dereference NULL pointer.  Handle the
failure to avoid such invalid access.

Link: https://lkml.kernel.org/r/20231106233408.51159-3-sj@kernel.org
Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> [6.2+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/damon/sysfs-schemes.c