mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
lsm: cleanup initialize_lsm() and rename to lsm_init_single()
Rename initialize_lsm() to be more consistent with the rest of the LSM initialization changes and rework the function itself to better fit with the "exit on fail" coding pattern. Reviewed-by: Kees Cook <kees@kernel.org> Reviewed-by: John Johansen <john.johansen@canonical.com> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
@@ -169,6 +169,7 @@ out:
|
||||
lsm_is_enabled(lsm) ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lsm_blob_size_update - Update the LSM blob size and offset information
|
||||
* @sz_req: the requested additional blob size
|
||||
@@ -225,16 +226,20 @@ static void __init lsm_prepare(struct lsm_info *lsm)
|
||||
lsm_blob_size_update(&blobs->lbs_bpf_token, &blob_sizes.lbs_bpf_token);
|
||||
}
|
||||
|
||||
/* Initialize a given LSM, if it is enabled. */
|
||||
static void __init initialize_lsm(struct lsm_info *lsm)
|
||||
/**
|
||||
* lsm_init_single - Initialize a given LSM
|
||||
* @lsm: LSM definition
|
||||
*/
|
||||
static void __init lsm_init_single(struct lsm_info *lsm)
|
||||
{
|
||||
if (lsm_is_enabled(lsm)) {
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
init_debug("initializing %s\n", lsm->id->name);
|
||||
ret = lsm->init();
|
||||
WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret);
|
||||
}
|
||||
if (!lsm_is_enabled(lsm))
|
||||
return;
|
||||
|
||||
init_debug("initializing %s\n", lsm->id->name);
|
||||
ret = lsm->init();
|
||||
WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +384,7 @@ static void __init lsm_init_ordered(void)
|
||||
panic("%s: early task alloc failed.\n", __func__);
|
||||
|
||||
lsm_order_for_each(lsm) {
|
||||
initialize_lsm(*lsm);
|
||||
lsm_init_single(*lsm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +434,7 @@ int __init early_security_init(void)
|
||||
lsm_enabled_set(lsm, true);
|
||||
lsm_order_append(lsm, "early");
|
||||
lsm_prepare(lsm);
|
||||
initialize_lsm(lsm);
|
||||
lsm_init_single(lsm);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user