Skip to content

Commit 33c1c6d

Browse files
lgs2513maddy-kerneldev
authored andcommitted
powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()
As kcalloc() may fail, check its return value to avoid a NULL pointer dereference when passing it to of_property_read_u32_array(). Fixes: 790a166 ("powerpc/smp: Parse ibm,thread-groups with multiple properties") Cc: stable@vger.kernel.org Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20250923133235.1862108-1-lgs201920130244@gmail.com
1 parent 4acc549 commit 33c1c6d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/powerpc/kernel/smp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ static int parse_thread_groups(struct device_node *dn,
822822

823823
count = of_property_count_u32_elems(dn, "ibm,thread-groups");
824824
thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL);
825+
if (!thread_group_array)
826+
return -ENOMEM;
825827
ret = of_property_read_u32_array(dn, "ibm,thread-groups",
826828
thread_group_array, count);
827829
if (ret)

0 commit comments

Comments
 (0)