2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

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: 82a08bde3c ("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>
This commit is contained in:
Honggyu Kim 2025-07-02 09:02:03 +09:00 committed by Andrew Morton
parent f1221c8442
commit ddba1b6cf4

View File

@ -164,8 +164,12 @@ static int damon_sample_mtier_enable_store(
if (enable == enabled) if (enable == enabled)
return 0; return 0;
if (enable) if (enable) {
return damon_sample_mtier_start(); err = damon_sample_mtier_start();
if (err)
enable = false;
return err;
}
damon_sample_mtier_stop(); damon_sample_mtier_stop();
return 0; return 0;
} }