Skip to content

Commit 7f74c06

Browse files
tobluxtsbogend
authored andcommitted
MIPS: CPS: Fix potential NULL pointer dereferences in cps_prepare_cpus()
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>
1 parent cc3e3d3 commit 7f74c06

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/mips/kernel/smp-cps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
332332
mips_cps_cluster_bootcfg = kcalloc(nclusters,
333333
sizeof(*mips_cps_cluster_bootcfg),
334334
GFP_KERNEL);
335+
if (!mips_cps_cluster_bootcfg)
336+
goto err_out;
335337

336338
if (nclusters > 1)
337339
mips_cm_update_property();
@@ -348,6 +350,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
348350
mips_cps_cluster_bootcfg[cl].core_power =
349351
kcalloc(BITS_TO_LONGS(ncores), sizeof(unsigned long),
350352
GFP_KERNEL);
353+
if (!mips_cps_cluster_bootcfg[cl].core_power)
354+
goto err_out;
351355

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

0 commit comments

Comments
 (0)