Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+15 -10
+15 -10
security/lsm_init.c
··· 169 169 lsm_is_enabled(lsm) ? "enabled" : "disabled"); 170 170 } 171 171 172 + 172 173 /** 173 174 * lsm_blob_size_update - Update the LSM blob size and offset information 174 175 * @sz_req: the requested additional blob size ··· 226 225 lsm_blob_size_update(&blobs->lbs_bpf_token, &blob_sizes.lbs_bpf_token); 227 226 } 228 227 229 - /* Initialize a given LSM, if it is enabled. */ 230 - static void __init initialize_lsm(struct lsm_info *lsm) 228 + /** 229 + * lsm_init_single - Initialize a given LSM 230 + * @lsm: LSM definition 231 + */ 232 + static void __init lsm_init_single(struct lsm_info *lsm) 231 233 { 232 - if (lsm_is_enabled(lsm)) { 233 - int ret; 234 + int ret; 234 235 235 - init_debug("initializing %s\n", lsm->id->name); 236 - ret = lsm->init(); 237 - WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret); 238 - } 236 + if (!lsm_is_enabled(lsm)) 237 + return; 238 + 239 + init_debug("initializing %s\n", lsm->id->name); 240 + ret = lsm->init(); 241 + WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret); 239 242 } 240 243 241 244 /** ··· 384 379 panic("%s: early task alloc failed.\n", __func__); 385 380 386 381 lsm_order_for_each(lsm) { 387 - initialize_lsm(*lsm); 382 + lsm_init_single(*lsm); 388 383 } 389 384 } 390 385 ··· 434 429 lsm_enabled_set(lsm, true); 435 430 lsm_order_append(lsm, "early"); 436 431 lsm_prepare(lsm); 437 - initialize_lsm(lsm); 432 + lsm_init_single(lsm); 438 433 } 439 434 440 435 return 0;