Skip to content

Commit

Permalink
MIPS: CPS: Fix potential NULL pointer dereferences in cps_prepare_cpus()
Browse files Browse the repository at this point in the history
Check the return values of kcalloc() and exit early to avoid potential
NULL pointer dereferences.

Compile-tested only.

Cc: stable@vger.kernel.org
Fixes: 75fa6a5 ("MIPS: CPS: Introduce struct cluster_boot_config")
Fixes: 0856c14 ("MIPS: CPS: Boot CPUs in secondary clusters")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
  • Loading branch information
Thorsten Blum authored and Thomas Bogendoerfer committed Apr 27, 2025
1 parent cc3e3d3 commit 7f74c06
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/mips/kernel/smp-cps.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
mips_cps_cluster_bootcfg = kcalloc(nclusters,
sizeof(*mips_cps_cluster_bootcfg),
GFP_KERNEL);
if (!mips_cps_cluster_bootcfg)
goto err_out;

if (nclusters > 1)
mips_cm_update_property();
Expand All @@ -348,6 +350,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
mips_cps_cluster_bootcfg[cl].core_power =
kcalloc(BITS_TO_LONGS(ncores), sizeof(unsigned long),
GFP_KERNEL);
if (!mips_cps_cluster_bootcfg[cl].core_power)
goto err_out;

/* Allocate VPE boot configuration structs */
for (c = 0; c < ncores; c++) {
Expand Down

0 comments on commit 7f74c06

Please sign in to comment.