]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cgroup/cpuset: Free sched domains on rebuild guard failure
authorGuopeng Zhang <zhangguopeng@kylinos.cn>
Thu, 28 May 2026 09:37:42 +0000 (17:37 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 29 May 2026 18:23:18 +0000 (08:23 -1000)
generate_sched_domains() returns sched-domain masks and optional
attributes that are normally handed to partition_sched_domains(), which
takes ownership of them.

rebuild_sched_domains_locked() has a WARN guard after
generate_sched_domains() and before partition_sched_domains() to avoid
passing offline CPUs into the scheduler domain rebuild path. If that
guard fires, the function currently returns directly without freeing
the generated doms and attr.

Free the generated sched-domain masks and attributes before returning
from the guard failure path.

Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c

index 8500e4341c6035605f622875592383d3a7dbbbc5..2a4122b8db295b4f9fc7bb17a731798df581dbba 100644 (file)
@@ -1004,8 +1004,11 @@ void rebuild_sched_domains_locked(void)
        * prevent the panic.
        */
        for (i = 0; doms && i < ndoms; i++) {
-               if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask)))
+               if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) {
+                       free_sched_domains(doms, ndoms);
+                       kfree(attr);
                        return;
+               }
        }
 
        /* Have scheduler rebuild the domains */