Skip to content
/ linux Public

Commit 9d0ca11

Browse files
lgs2513Sasha Levin
authored andcommitted
powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()
[ Upstream commit 33c1c6d ] 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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 442f5db commit 9d0ca11

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
@@ -830,6 +830,8 @@ static int parse_thread_groups(struct device_node *dn,
830830

831831
count = of_property_count_u32_elems(dn, "ibm,thread-groups");
832832
thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL);
833+
if (!thread_group_array)
834+
return -ENOMEM;
833835
ret = of_property_read_u32_array(dn, "ibm,thread-groups",
834836
thread_group_array, count);
835837
if (ret)

0 commit comments

Comments
 (0)