Le 22/09/2025 à 18:07, Christophe Leroy a écrit :


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: [email protected]

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/[email protected]/

Mine, was https://lore.kernel.org/lkml/[email protected]/

and apparently, there as been 3 v1 : https://lore.kernel.org/lkml/?q=powerpc%2Fsmp%3A+Add+check+for+kcalloc%28%29+in+parse_thread_groups%28%29

:/

CJ



CJ


Signed-off-by: Guangshuo Li <[email protected]>
---
  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 via email to