damon_destroy_ctx(damon_stat_context);
}
-static bool damon_stat_init_called;
-
static int damon_stat_enabled_store(
const char *val, const struct kernel_param *kp)
{
if (is_enabled == enabled)
return 0;
- if (!damon_stat_init_called)
+ if (!damon_initialized())
/*
* probably called from command line parsing (parse_args()).
* Cannot call damon_new_ctx(). Let damon_stat_init() handle.
{
int err = 0;
- damon_stat_init_called = true;
+ if (!damon_initialized()) {
+ err = -ENOMEM;
+ goto out;
+ }
/* probably set via command line */
if (enabled)
err = damon_stat_start();
+out:
if (err && enabled)
enabled = false;
return err;