Skip to content

Commit ddba1b6

Browse files
honggyukimakpm00
authored andcommitted
samples/damon: fix damon sample mtier for start failure
The damon_sample_mtier_start() can fail so we must reset the "enable" parameter to "false" again for proper rollback. In such cases, setting Y to "enable" then N triggers the similar crash with mtier because damon sample start failed but the "enable" stays as Y. Link: https://lkml.kernel.org/r/20250702000205.1921-4-honggyu.kim@sk.com Fixes: 82a08bd ("samples/damon: implement a DAMON module for memory tiering") Signed-off-by: Honggyu Kim <honggyu.kim@sk.com> Reviewed-by: SeongJae Park <sj@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f1221c8 commit ddba1b6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

samples/damon/mtier.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ static int damon_sample_mtier_enable_store(
164164
if (enable == enabled)
165165
return 0;
166166

167-
if (enable)
168-
return damon_sample_mtier_start();
167+
if (enable) {
168+
err = damon_sample_mtier_start();
169+
if (err)
170+
enable = false;
171+
return err;
172+
}
169173
damon_sample_mtier_stop();
170174
return 0;
171175
}

0 commit comments

Comments
 (0)