2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

bitmap-for-6.17-rc5

Fix sched_numa_find_nth_cpu() if mask offline
 
 sched_numa_find_nth_cpu() uses a bsearch to look for the 'closest'
 CPU in sched_domains_numa_masks and given cpus mask. However they
 might not intersect if all CPUs in the cpus mask are offline. bsearch
 will return NULL in that case, bail out instead of dereferencing a
 bogus pointer.
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEi8GdvG6xMhdgpu/4sUSA/TofvsgFAmi4cKQACgkQsUSA/Tof
 vsj1CAwAlnWawsvxSGW0CL40ogrvlwbkmBGf6fLATqg7eX+aBvDQ7n02g7a4Ebwx
 C4MSpihn6C7J29DfPj0wT6R5SlaXSm9EqwGcEuD2YegiVGRpVcIdGSHa5//8qqt2
 TOnMEDjagaFPYd3diomAC9EwCDX/uHt23PSa3LCdGKAqugfdPL9fs2BSKBucgS8G
 evqHsi2G0CLuCSFdkdetLw3ifMFnskOBL6PjsyUIUjaXm6gWCNM02bzUtDWA6lBk
 yDOqb5LaOSM5Aual3ecuMCe2jHMeCIOesZ95j5o8VBmjC/70cKPHVCsPJyXwjNuv
 prIZEJFNHBEO/8oGZZpraKZG8VMX7KhW1Ds2Kjk8AcnMXkpCYQsN9RvhbImwAs1E
 b6QsuYmEC2n4d5UT0tv523p5o1xY5TnFRplIoJJ1sdL6ZTBbAJGqhjenb0WUfN1w
 ZroWnnSsOCvlIfA/9QrLAewn+Gk8GXUEokhNAalCV2ayNPBFBUftXpjAeCPhqDge
 Ixc+V5PY
 =9kv/
 -----END PGP SIGNATURE-----

Merge tag 'bitmap-for-6.17-rc5' of https://github.com/norov/linux

Pull bitmap fix from Yury Norov:
 "Fix sched_numa_find_nth_cpu() if mask offline

  sched_numa_find_nth_cpu() uses a bsearch to look for the 'closest' CPU
  in sched_domains_numa_masks and given cpus mask. However they might
  not intersect if all CPUs in the cpus mask are offline.

  bsearch will return NULL in that case, bail out instead of
  dereferencing a bogus pointer"

* tag 'bitmap-for-6.17-rc5' of https://github.com/norov/linux:
  sched: Fix sched_numa_find_nth_cpu() if mask offline
This commit is contained in:
Linus Torvalds 2025-09-03 11:10:36 -07:00
commit ec299e4dc2

View File

@ -2201,6 +2201,8 @@ int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
goto unlock; goto unlock;
hop_masks = bsearch(&k, k.masks, sched_domains_numa_levels, sizeof(k.masks[0]), hop_cmp); hop_masks = bsearch(&k, k.masks, sched_domains_numa_levels, sizeof(k.masks[0]), hop_cmp);
if (!hop_masks)
goto unlock;
hop = hop_masks - k.masks; hop = hop_masks - k.masks;
ret = hop ? ret = hop ?