Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: "Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
	"Guangshuo Li" <lgs201920130244@gmail.com>,
	"Madhavan Srinivasan" <maddy@linux.ibm.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Naveen N Rao" <naveen@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH v2] powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()
Date: Mon, 22 Sep 2025 18:07:53 +0200	[thread overview]
Message-ID: <496a8ed4-b416-47f9-be1f-cda5472d004d@csgroup.eu> (raw)
In-Reply-To: <a7453bdc-16f3-43e6-a06d-bd6144eeae72@wanadoo.fr>



Le 22/09/2025 à 17:38, Christophe JAILLET a écrit :
> Le 22/09/2025 à 17:10, Guangshuo Li a écrit :
>> 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@vger.kernel.org
> 
> Signed-off-by that was part of v1, is missing in v2.

I see it below the ---

> 
>> ---
>> changelog:
>> v2:
>> - Return -ENOMEM directly on allocation failure.
> 
> Except for a newline that is removed, v2 is the same as v1, or I miss 
> something?

v1 was:

+       if (!thread_group_array) {
+               ret = -ENOMEM;
+               goto out_free;
+       }

Which was wrong.

Well maybe there was several v1, I'm talking about 
https://lore.kernel.org/all/20250918131513.3557422-1-lgs201920130244@gmail.com/

> 
> CJ
> 
>>
>> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
>> ---
>>   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)
> 


  reply	other threads:[~2025-09-22 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-22 15:10 [PATCH v2] powerpc/smp: Add check for kcalloc() failure in parse_thread_groups() Guangshuo Li
2025-09-22 15:38 ` Christophe JAILLET
2025-09-22 16:07   ` Christophe Leroy [this message]
2025-09-22 16:27     ` Christophe JAILLET
2025-09-22 16:05 ` Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=496a8ed4-b416-47f9-be1f-cda5472d004d@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=ego@linux.vnet.ibm.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox