diff options
| author | SeongJae Park <sj@kernel.org> | 2025-07-06 12:32:04 -0700 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2025-07-13 16:38:34 -0700 |
| commit | 964314344eab7bc43e38a32be281c5ea0609773b (patch) | |
| tree | d7185e883626987e450e6e4cc11ec056c80e5a7f /samples | |
| parent | 2780505ec2b42c07853b34640bc63279ac2bb53b (diff) | |
samples/damon/mtier: support boot time enable setup
If 'enable' parameter of the 'mtier' DAMON sample module is set at boot
time via the kernel command line, memory allocation is tried before the
slab is initialized. As a result kernel NULL pointer dereference BUG can
happen. Fix it by checking the initialization status.
Link: https://lkml.kernel.org/r/20250706193207.39810-4-sj@kernel.org
Fixes: 82a08bde3cf7 ("samples/damon: implement a DAMON module for memory tiering")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/damon/mtier.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c index 97892ade7f31..bc9d8195da87 100644 --- a/samples/damon/mtier.c +++ b/samples/damon/mtier.c @@ -157,6 +157,8 @@ static void damon_sample_mtier_stop(void) damon_destroy_ctx(ctxs[1]); } +static bool init_called; + static int damon_sample_mtier_enable_store( const char *val, const struct kernel_param *kp) { @@ -182,6 +184,14 @@ static int damon_sample_mtier_enable_store( static int __init damon_sample_mtier_init(void) { + int err = 0; + + init_called = true; + if (enable) { + err = damon_sample_mtier_start(); + if (err) + enable = false; + } return 0; } |
