Skip to content

Commit 0199390

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs: dealloc repeat_call_control if damon_call() fails
damon_call() for repeat_call_control of DAMON_SYSFS could fail if somehow the kdamond is stopped before the damon_call(). It could happen, for example, when te damon context was made for monitroing of a virtual address processes, and the process is terminated immediately, before the damon_call() invocation. In the case, the dyanmically allocated repeat_call_control is not deallocated and leaked. Fix the leak by deallocating the repeat_call_control under the damon_call() failure. This issue is discovered by sashiko [1]. Link: https://lkml.kernel.org/r/[email protected] Link: https://lore.kernel.org/[email protected] [1] Fixes: 04a06b1 ("mm/damon/sysfs: use dynamically allocated repeat mode damon_call_control") Signed-off-by: SeongJae Park <[email protected]> Cc: <[email protected]> [6.17+] Signed-off-by: Andrew Morton <[email protected]>
1 parent cece9dc commit 0199390

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mm/damon/sysfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,8 @@ static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond)
16701670
repeat_call_control->data = kdamond;
16711671
repeat_call_control->repeat = true;
16721672
repeat_call_control->dealloc_on_cancel = true;
1673-
damon_call(ctx, repeat_call_control);
1673+
if (damon_call(ctx, repeat_call_control))
1674+
kfree(repeat_call_control);
16741675
return err;
16751676
}
16761677

0 commit comments

Comments
 (0)