[PATCH v2] powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()

Christophe Leroy christophe.leroy at csgroup.eu
Tue Sep 23 02:05:19 AEST 2025



Le 22/09/2025 à 17:10, Guangshuo Li a écrit :
> [Vous ne recevez pas souvent de courriers de lgs201920130244 at gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> As kcalloc() may fail, check its return value to avoid a NULL pointer
> dereference when passing it to of_property_read_u32_array().
> 
> Fixes: 790a1662d3a26 ("powerpc/smp: Parse ibm,thread-groups with multiple properties")
> Cc: stable at vger.kernel.org
> ---
> changelog:
> v2:
> - Return -ENOMEM directly on allocation failure.
> 
> Signed-off-by: Guangshuo Li <lgs201920130244 at gmail.com>

The Signed-off-by: must be above the ---, otherwise it will be lost when 
applying the commit.

With that fixed,

Reviewed-by: Christophe Leroy <christophe.leroy at csgroup.eu>



> ---
>   arch/powerpc/kernel/smp.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 5ac7084eebc0..cfccb9389760 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -822,6 +822,8 @@ static int parse_thread_groups(struct device_node *dn,
> 
>          count = of_property_count_u32_elems(dn, "ibm,thread-groups");
>          thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL);
> +       if (!thread_group_array)
> +               return -ENOMEM;
>          ret = of_property_read_u32_array(dn, "ibm,thread-groups",
>                                           thread_group_array, count);
>          if (ret)
> --
> 2.43.0
> 



More information about the Linuxppc-dev mailing list