Skip to content

Commit

Permalink
mm/damon/sysfs-schemes: handle tried regions sysfs directory allocati…
Browse files Browse the repository at this point in the history
…on failure

commit 8405568 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: 9277d03 ("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>
  • Loading branch information
sjp38 authored and gregkh committed Nov 28, 2023
1 parent fadc9f4 commit 2e4dec8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/damon/sysfs-schemes.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ damon_sysfs_scheme_regions_alloc(void)
struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions),
GFP_KERNEL);

if (!regions)
return NULL;

regions->kobj = (struct kobject){};
INIT_LIST_HEAD(&regions->regions_list);
regions->nr_regions = 0;
Expand Down

0 comments on commit 2e4dec8

Please sign in to comment.