[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7c0c53bc-1436-4a48-8afa-8bfff439ce67@csgroup.eu>
Date: Thu, 18 Sep 2025 17:17:55 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Guangshuo Li <lgs201920130244@...il.com>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>,
Naveen N Rao <naveen@...nel.org>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Thomas Gleixner <tglx@...utronix.de>,
"Gautham R. Shenoy" <ego@...ux.vnet.ibm.com>, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Cc: stable@...r.kernel.org
Subject: Re: [PATCH] powerpc/smp: Add check for kcalloc() in
parse_thread_groups()
Le 18/09/2025 à 15:15, Guangshuo Li a écrit :
> [Vous ne recevez pas souvent de courriers de lgs201920130244@...il.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@...r.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@...il.com>
> ---
> arch/powerpc/kernel/smp.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 5ac7084eebc0..fa0cd3f7a93c 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -822,6 +822,10 @@ 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) {
> + ret = -ENOMEM;
> + goto out_free;
out_free does nothing as thread_group_array is NULL, so don't goto
out_free, instead return -ENOMEM immediately:
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
>
Powered by blists - more mailing lists