mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
	Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
	linux-kernel@vger.kernel.org, chleroy@kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Subject: [PATCH] powerpc/smp: Handle missing ibm,thread-groups in parse_thread_groups()
Date: Tue, 10 Nov 2026 19:13:24 +0530	[thread overview]
Message-ID: <39282c731de90f47678952e471236ef22e9d4b15.1794317777.git.ritesh.list@gmail.com> (raw)

Power systems can have ibm,thread-groups properly absent like in one of
the PowerNV Power9 boxes where there was a warning splat reported on
7.4-rc2:

  WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0x174/0x1a0, CPU#124: swapper/124/1
  ...
  Call Trace:
   __kmalloc_noprof+0x490/0x690
   _kzalloc_noprof.constprop.0+0x1c/0x7c
   init_thread_group_cache_map+0xd0/0x2d4
   smp_prepare_cpus+0x2bc/0x484
   kernel_init_freeable+0x168/0x3c4
   kernel_init+0x34/0x1ac

This happens because today we don't check for whether the properly is
present or not and directly pass the return value of
of_property_count_u32_elems(), to the allocator.

This went unnoticed because earlier kcalloc() caught the overflow due to
check_mul_overflow() check and returned NULL.
But since commit 0af298e62e5c ("treewide: refresh kmalloc_obj()
conversions") switched this call to kzalloc_objs(), size_mul() saturates
the size to SIZE_MAX instead and we now get a warning at boot.

Bail out early if the property is missing or empty. Follow the return
value as documented in kernel doc of parse_thread_groups() function.

Fixes: 790a1662d3a2 ("powerpc/smp: Parse ibm,thread-groups with multiple properties")
Reported-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 arch/powerpc/kernel/smp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 7a25eaa59e62..9a0f63e43821 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -824,6 +824,10 @@ 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;
+	if (!count)
+		return -ENODATA;
 	thread_group_array = kzalloc_objs(u32, count);
 	if (!thread_group_array)
 		return -ENOMEM;
--
2.39.5


             reply	other threads:[~2026-11-10 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 13:43 Ritesh Harjani (IBM) [this message]
2026-11-10 14:37 ` Shrikanth Hegde
2026-11-10 15:23   ` Ritesh Harjani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39282c731de90f47678952e471236ef22e9d4b15.1794317777.git.ritesh.list@gmail.com \
    --to=ritesh.list@gmail.com \
    --cc=chleroy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=sshegde@linux.ibm.com \
    --cc=venkat88@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®