Skip to content

Commit 1338fb5

Browse files
sjp38gregkh
authored andcommitted
samples/damon/prcl: fix boot time enable crash
[ Upstream commit 2780505 ] If 'enable' parameter of the 'prcl' 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/[email protected] Fixes: 2aca254 ("samples/damon: introduce a skeleton of a smaple DAMON module for proactive reclamation") Signed-off-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Stable-dep-of: c62cff4 ("samples/damon/mtier: avoid starting DAMON before initialization") Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9414521 commit 1338fb5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

samples/damon/prcl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ static void damon_sample_prcl_stop(void)
109109
put_pid(target_pidp);
110110
}
111111

112+
static bool init_called;
113+
112114
static int damon_sample_prcl_enable_store(
113115
const char *val, const struct kernel_param *kp)
114116
{
@@ -134,6 +136,14 @@ static int damon_sample_prcl_enable_store(
134136

135137
static int __init damon_sample_prcl_init(void)
136138
{
139+
int err = 0;
140+
141+
init_called = true;
142+
if (enable) {
143+
err = damon_sample_prcl_start();
144+
if (err)
145+
enable = false;
146+
}
137147
return 0;
138148
}
139149

0 commit comments

Comments
 (0)