* [PATCH] powerpc/smp: parse_thread_groups() return error on missing property
@ 2026-11-14 7:38 John Ogness
2026-11-14 9:36 ` Sebastian Andrzej Siewior
2026-11-14 12:31 ` Ritesh Harjani
0 siblings, 2 replies; 3+ messages in thread
From: John Ogness @ 2026-11-14 7:38 UTC (permalink / raw)
To: Madhavan Srinivasan
Cc: Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Sebastian Andrzej Siewior,
linuxppc-dev, linux-kernel
parse_thread_groups() is supposed to return -EINVAL if the property
does not exist and -ENODATA if property does not have a value.
However, it is currently assuming it exists and blindly calling
kzalloc_objs() with whatever of_property_count_u32_elems() returns.
Since of_property_count_u32_elems() returns exactly these same error
values in those cases, simply return with the returned error value.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
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 7a25eaa59e626..58824f5f4c800 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -824,6 +824,8 @@ static int parse_thread_groups(struct device_node *dn,
int i = 0;
count = of_property_count_u32_elems(dn, "ibm,thread-groups");
+ if (count < 0)
+ return count;
thread_group_array = kzalloc_objs(u32, count);
if (!thread_group_array)
return -ENOMEM;
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/smp: parse_thread_groups() return error on missing property
2026-11-14 7:38 [PATCH] powerpc/smp: parse_thread_groups() return error on missing property John Ogness
@ 2026-11-14 9:36 ` Sebastian Andrzej Siewior
2026-11-14 12:31 ` Ritesh Harjani
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-11-14 9:36 UTC (permalink / raw)
To: John Ogness
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde, linuxppc-dev, linux-kernel, Kees Cook,
Vlastimil Babka
+ Kees, Vlastimil
On 2026-11-14 08:44:57 [+0106], John Ogness wrote:
> parse_thread_groups() is supposed to return -EINVAL if the property
> does not exist and -ENODATA if property does not have a value.
> However, it is currently assuming it exists and blindly calling
> kzalloc_objs() with whatever of_property_count_u32_elems() returns.
>
> Since of_property_count_u32_elems() returns exactly these same error
> values in those cases, simply return with the returned error value.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: 0af298e62e5cf ("treewide: refresh kmalloc_obj() conversions")
But… The difference in the commit was:
|- thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL);
|+ thread_group_array = kzalloc_objs(u32, count);
| if (!thread_group_array)
| return -ENOMEM;
kcalloc() returned NULL on an overflow and did not continue with the
allocation. So the check below worked.
kzalloc_objs() on the other hand returns for the overflow SIZE_MAX and
passes this down to the allocator. We still get a NULL pointer but with
a warning (from ___kmalloc_large_node()).
Is the warning on purpose now?
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/smp: parse_thread_groups() return error on missing property
2026-11-14 7:38 [PATCH] powerpc/smp: parse_thread_groups() return error on missing property John Ogness
2026-11-14 9:36 ` Sebastian Andrzej Siewior
@ 2026-11-14 12:31 ` Ritesh Harjani
1 sibling, 0 replies; 3+ messages in thread
From: Ritesh Harjani @ 2026-11-14 12:31 UTC (permalink / raw)
To: John Ogness, Madhavan Srinivasan
Cc: Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
Shrikanth Hegde, Sebastian Andrzej Siewior, linuxppc-dev,
linux-kernel
John Ogness <john.ogness@linutronix.de> writes:
> parse_thread_groups() is supposed to return -EINVAL if the property
> does not exist and -ENODATA if property does not have a value.
> However, it is currently assuming it exists and blindly calling
> kzalloc_objs() with whatever of_property_count_u32_elems() returns.
>
> Since of_property_count_u32_elems() returns exactly these same error
> values in those cases, simply return with the returned error value.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
> arch/powerpc/kernel/smp.c | 2 ++
> 1 file changed, 2 insertions(+)
Thanks! However, the fix for this is already queued to powerpc's fixes branch.
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=126b47221b7b98d83c118781ce724c0515d86d9c
-ritesh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-14 12:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 7:38 [PATCH] powerpc/smp: parse_thread_groups() return error on missing property John Ogness
2026-11-14 9:36 ` Sebastian Andrzej Siewior
2026-11-14 12:31 ` Ritesh Harjani
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.