@@ -840,21 +840,24 @@ void init_mem_debugging_and_hardening(void)
840
840
}
841
841
#endif
842
842
843
- if (_init_on_alloc_enabled_early ) {
844
- if (page_poisoning_requested )
845
- pr_info ("mem auto-init: CONFIG_PAGE_POISONING is on, "
846
- "will take precedence over init_on_alloc\n" );
847
- else
848
- static_branch_enable (& init_on_alloc );
849
- }
850
- if (_init_on_free_enabled_early ) {
851
- if (page_poisoning_requested )
852
- pr_info ("mem auto-init: CONFIG_PAGE_POISONING is on, "
853
- "will take precedence over init_on_free\n" );
854
- else
855
- static_branch_enable (& init_on_free );
843
+ if ((_init_on_alloc_enabled_early || _init_on_free_enabled_early ) &&
844
+ page_poisoning_requested ) {
845
+ pr_info ("mem auto-init: CONFIG_PAGE_POISONING is on, "
846
+ "will take precedence over init_on_alloc and init_on_free\n" );
847
+ _init_on_alloc_enabled_early = false;
848
+ _init_on_free_enabled_early = false;
856
849
}
857
850
851
+ if (_init_on_alloc_enabled_early )
852
+ static_branch_enable (& init_on_alloc );
853
+ else
854
+ static_branch_disable (& init_on_alloc );
855
+
856
+ if (_init_on_free_enabled_early )
857
+ static_branch_enable (& init_on_free );
858
+ else
859
+ static_branch_disable (& init_on_free );
860
+
858
861
#ifdef CONFIG_DEBUG_PAGEALLOC
859
862
if (!debug_pagealloc_enabled ())
860
863
return ;
0 commit comments