Fix reading uninitialized cpumask and using it to validate the nohz_full=
and isolcpus= kernel command line parameters.

An older version of a patch from lkml was incorporated into linux-yocto,
whereas a newer, rebased version was later published. See:
https://lore.kernel.org/lkml/[email protected]/

Signed-off-by: Adrian Cinal <[email protected]>
---
 kernel/sched/isolation.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 73386019efcb..b97d6e05013d 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -119,6 +119,12 @@ static int __init housekeeping_setup(char *str, unsigned 
long flags)
                }
        }
 
+       alloc_bootmem_cpumask_var(&non_housekeeping_mask);
+       if (cpulist_parse(str, non_housekeeping_mask) < 0) {
+               pr_warn("Housekeeping: nohz_full= or isolcpus= incorrect CPU 
range\n");
+               goto free_non_housekeeping_mask;
+       }
+
        if (!cpumask_subset(non_housekeeping_mask, cpu_possible_mask)) {
                pr_info("housekeeping: kernel parameter 'nohz_full=' or 
'isolcpus=' contains nonexistent CPUs.\n");
                cpumask_and(non_housekeeping_mask, cpu_possible_mask,
@@ -128,12 +134,6 @@ static int __init housekeeping_setup(char *str, unsigned 
long flags)
        if (cpumask_empty(non_housekeeping_mask)) {
                pr_info("housekeeping: kernel parameter 'nohz_full=' or 
'isolcpus=' has no valid CPUs.\n");
                free_bootmem_cpumask_var(non_housekeeping_mask);
-               return 0;
-       }
-
-       alloc_bootmem_cpumask_var(&non_housekeeping_mask);
-       if (cpulist_parse(str, non_housekeeping_mask) < 0) {
-               pr_warn("Housekeeping: nohz_full= or isolcpus= incorrect CPU 
range\n");
                goto free_non_housekeeping_mask;
        }
 
-- 
2.41.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#12797): 
https://lists.yoctoproject.org/g/linux-yocto/message/12797
Mute This Topic: https://lists.yoctoproject.org/mt/99772129/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to