Commit f1221c84 authored by Honggyu Kim's avatar Honggyu Kim Committed by Andrew Morton
Browse files

samples/damon: fix damon sample wsse for start failure

The damon_sample_wsse_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 wsse because damon sample start failed but the "enable" stays as Y.

Link: https://lkml.kernel.org/r/20250702000205.1921-3-honggyu.kim@sk.com


Fixes: b757c6cf ("samples/damon/wsse: start and stop DAMON as the user requests")
Signed-off-by: default avatarHonggyu Kim <honggyu.kim@sk.com>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d9e01c62
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -102,8 +102,12 @@ static int damon_sample_wsse_enable_store(
	if (enable == enabled)
		return 0;

	if (enable)
		return damon_sample_wsse_start();
	if (enable) {
		err = damon_sample_wsse_start();
		if (err)
			enable = false;
		return err;
	}
	damon_sample_wsse_stop();
	return 0;
}