From: Steven Noonan <steven@uplinklabs.net>
To: linux-kernel@vger.kernel.org
Cc: Steven Noonan <steven@uplinklabs.net>,
Ariadne Conill <ariadne@ariadne.space>,
Yazen Ghannam <yazen.ghannam@amd.com>,
x86@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 2/2] x86/amd_node: fix null pointer dereference if amd_smn_init failed
Date: Fri, 14 Nov 2025 19:57:46 +0000 [thread overview]
Message-ID: <20251114195730.1503879-2-steven@uplinklabs.net> (raw)
In-Reply-To: <20251114195730.1503879-1-steven@uplinklabs.net>
[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]
We should be checking the `smn_exclusive` flag before anything else,
because that indicates whether we got through `amd_smn_init`
successfully.
Without this change, we dereference `amd_roots` even though it may not
be allocated.
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
CC: Yazen Ghannam <yazen.ghannam@amd.com>
CC: x86@vger.kernel.org
CC: stable@vger.kernel.org
---
arch/x86/kernel/amd_node.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c
index cdc6ba224d4ad..919932339f4a2 100644
--- a/arch/x86/kernel/amd_node.c
+++ b/arch/x86/kernel/amd_node.c
@@ -88,6 +88,9 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b
struct pci_dev *root;
int err = -ENODEV;
+ if (!smn_exclusive)
+ return err;
+
if (node >= amd_num_nodes())
return err;
@@ -95,9 +98,6 @@ static int __amd_s
mn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b
if (!root)
return err;
- if (!smn_exclusive)
- return err;
-
guard(mutex)(&smn_mutex);
err = pci_write_config_dword(root, i_off, address);
--
2.51.2
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 322 bytes --]
next prev parent reply other threads:[~2025-11-14 19:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 19:57 [PATCH 1/2] x86/amd_node: fix integer divide by zero during init Steven Noonan
2025-11-14 19:57 ` Steven Noonan [this message]
2025-12-03 20:54 ` [PATCH 2/2] x86/amd_node: fix null pointer dereference if amd_smn_init failed Yazen Ghannam
2025-12-03 20:45 ` [PATCH 1/2] x86/amd_node: fix integer divide by zero during init Yazen Ghannam
2025-12-04 20:16 ` Steven Noonan
2025-12-05 15:37 ` Yazen Ghannam
2025-12-03 21:18 ` Borislav Petkov
2025-12-04 16:45 ` Yazen Ghannam
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=20251114195730.1503879-2-steven@uplinklabs.net \
--to=steven@uplinklabs.net \
--cc=ariadne@ariadne.space \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=x86@vger.kernel.org \
--cc=yazen.ghannam@amd.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®