Skip to content

Commit 1c8e234

Browse files
SupremacistLeviakpm00
authored andcommitted
damon/sysfs: fix possible memleak on damon_sysfs_add_target
When damon_sysfs_add_target couldn't find proper task, New allocated damon_target structure isn't registered yet, So, it's impossible to free new allocated one by damon_sysfs_destroy_targets. By calling damon_add_target as soon as allocating new target, Fix this possible memory leak. Link: https://lkml.kernel.org/r/[email protected] Fixes: a61ea56 ("mm/damon/sysfs: link DAMON for virtual address spaces monitoring") Signed-off-by: Levi Yun <[email protected]> Signed-off-by: SeongJae Park <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Cc: <[email protected]> [5.17.x] Signed-off-by: Andrew Morton <[email protected]>
1 parent 30c1936 commit 1c8e234

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/damon/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,12 +2182,12 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target,
21822182

21832183
if (!t)
21842184
return -ENOMEM;
2185+
damon_add_target(ctx, t);
21852186
if (damon_target_has_pid(ctx)) {
21862187
t->pid = find_get_pid(sys_target->pid);
21872188
if (!t->pid)
21882189
goto destroy_targets_out;
21892190
}
2190-
damon_add_target(ctx, t);
21912191
err = damon_sysfs_set_regions(t, sys_target->regions);
21922192
if (err)
21932193
goto destroy_targets_out;

0 commit comments

Comments
 (0)