mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-14 11:19:08 +10:00
samples/damon/mtier: support boot time enable setup
commit964314344e
upstream. 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:82a08bde3c
("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a10eb32570
commit
dd1f0f4bfb
@ -151,6 +151,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)
|
||||
{
|
||||
@ -176,6 +178,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user