Re: [PATCH v2] x86/amd_node: Fix PCI device reference counting in amd_smn_init()

From: Borislav Petkov

Date: Thu Sep 10 2026 - 23:03:30 EST


On Thu, Sep 03, 2026 at 02:37:08PM -0500, Serge Hallyn (AMD) wrote:
> On Thu, Sep 03, 2026 at 10:43:25AM -0500, Yazen Ghannam wrote:
> > The local "root" pointer is a temporary variable used during the device
> > search. Therefore, refcount related to the search iterators should be
> > cleaned up after the search is complete.

Ontop of this:

From: "Borislav Petkov (AMD)" <bp@xxxxxxxxx>
Date: Thu, 10 Sep 2026 18:43:33 -0700
Subject: [PATCH] x86/topo: Initialize AMD nodes per package

Sashiko reports that

If amd_num_nodes() evaluates to 0, kzalloc_objs(*amd_roots, 0) returns the
truthy ZERO_SIZE_PTR (typically (void *)16).

Because ZERO_SIZE_PTR is not NULL, the subsequent check for !amd_roots will
fail to catch it, resulting in a divide-by-zero kernel panic on the very
next line during the __init boot phase.

Make sure topology_amd_nodes_per_pkg() doesn't return 0 - the AMD nodes per
package count can be trivially 1 if detection fails just like the rest
of the max* and num* packages topology attributes.

Closes: https://sashiko.dev/#/patchset/20260903154325.74343-1-yazen.ghannam%40amd.com
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
---
arch/x86/kernel/cpu/topology_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
index 6845e3c63fbb..7a7442981594 100644
--- a/arch/x86/kernel/cpu/topology_common.c
+++ b/arch/x86/kernel/cpu/topology_common.c
@@ -14,7 +14,7 @@
struct x86_topology_system x86_topo_system __ro_after_init;
EXPORT_SYMBOL_GPL(x86_topo_system);

-unsigned int __amd_nodes_per_pkg __ro_after_init;
+unsigned int __amd_nodes_per_pkg __ro_after_init = 1;
EXPORT_SYMBOL_GPL(__amd_nodes_per_pkg);

/* CPUs which are the primary SMT threads */
--
2.53.0

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette