]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()
authorGuangshuo Li <lgs201920130244@gmail.com>
Tue, 23 Sep 2025 13:32:35 +0000 (21:32 +0800)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:19 +0000 (07:21 -0500)
[ Upstream commit 33c1c6d8a28a2761ac74b0380b2563cf546c2a3a ]

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
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>
arch/powerpc/kernel/smp.c

index 68edb66c2964baa5e44d5021b6581f613c19ab78..0cd9c0c21af3ec5111e70f6a8b37705abc596b5b 100644 (file)
@@ -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)