Skip to content

Commit ae636ae

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs-schemes: handle tried region directory allocation failure
DAMON sysfs interface's before_damos_apply callback (damon_sysfs_before_damos_apply()), which creates the DAMOS tried regions for each DAMOS action applied region, is not handling the allocation failure for the sysfs directory data. As a result, NULL pointer derefeence is possible. Fix it by handling the case. Link: https://lkml.kernel.org/r/20231106233408.51159-4-sj@kernel.org Fixes: f1d13ca ("mm/damon/sysfs: implement DAMOS tried regions update command") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: <stable@vger.kernel.org> [6.2+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 8405568 commit ae636ae

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

mm/damon/sysfs-schemes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,8 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx,
18261826
return 0;
18271827

18281828
region = damon_sysfs_scheme_region_alloc(r);
1829+
if (!region)
1830+
return 0;
18291831
list_add_tail(&region->list, &sysfs_regions->regions_list);
18301832
sysfs_regions->nr_regions++;
18311833
if (kobject_init_and_add(&region->kobj,

0 commit comments

Comments
 (0)