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/[email protected] Fixes: 82a08bd ("samples/damon: implement a DAMON module for memory tiering") Signed-off-by: Honggyu Kim <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f1221c8 commit ddba1b6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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)