Skip to content

Commit 39e0f99

Browse files
committed
random: mark bootloader randomness code as __init
add_bootloader_randomness() and the variables it touches are only used during __init and not after, so mark these as __init. At the same time, unexport this, since it's only called by other __init code that's built-in. Cc: [email protected] Fixes: 428826f ("fdt: add support for rng-seed") Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 9b29b6b commit 39e0f99

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

drivers/char/random.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ static void __cold _credit_init_bits(size_t bits)
725725
**********************************************************************/
726726

727727
static bool used_arch_random;
728-
static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
729-
static bool trust_bootloader __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER);
728+
static bool trust_cpu __initdata = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
729+
static bool trust_bootloader __initdata = IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER);
730730
static int __init parse_trust_cpu(char *arg)
731731
{
732732
return kstrtobool(arg, &trust_cpu);
@@ -865,13 +865,12 @@ EXPORT_SYMBOL_GPL(add_hwgenerator_randomness);
865865
* Handle random seed passed by bootloader, and credit it if
866866
* CONFIG_RANDOM_TRUST_BOOTLOADER is set.
867867
*/
868-
void __cold add_bootloader_randomness(const void *buf, size_t len)
868+
void __init add_bootloader_randomness(const void *buf, size_t len)
869869
{
870870
mix_pool_bytes(buf, len);
871871
if (trust_bootloader)
872872
credit_init_bits(len * 8);
873873
}
874-
EXPORT_SYMBOL_GPL(add_bootloader_randomness);
875874

876875
#if IS_ENABLED(CONFIG_VMGENID)
877876
static BLOCKING_NOTIFIER_HEAD(vmfork_chain);

include/linux/random.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
struct notifier_block;
1414

1515
void add_device_randomness(const void *buf, size_t len);
16-
void add_bootloader_randomness(const void *buf, size_t len);
16+
void __init add_bootloader_randomness(const void *buf, size_t len);
1717
void add_input_randomness(unsigned int type, unsigned int code,
1818
unsigned int value) __latent_entropy;
1919
void add_interrupt_randomness(int irq) __latent_entropy;

0 commit comments

Comments
 (0)