mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Steven Noonan <steven@uplinklabs.net>
Cc: linux-kernel@vger.kernel.org,
	Ariadne Conill <ariadne@ariadne.space>,
	x86@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] x86/amd_node: fix null pointer dereference if amd_smn_init failed
Date: Wed, 3 Dec 2025 15:54:27 -0500	[thread overview]
Message-ID: <20251203205427.GB741246@yaz-khff2.amd.com> (raw)
In-Reply-To: <20251114195730.1503879-2-steven@uplinklabs.net>

On Fri, Nov 14, 2025 at 07:57:46PM +0000, Steven Noonan wrote:
> 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

Same feedback here as for patch 1.

> ---
>  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);
> -- 

This change looks good.

Did you encounter a NULL pointer dereference? Or did you find this by
code inspection?

Thanks,
Yazen

  reply	other threads:[~2025-12-03 20:54 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 ` [PATCH 2/2] x86/amd_node: fix null pointer dereference if amd_smn_init failed Steven Noonan
2025-12-03 20:54   ` Yazen Ghannam [this message]
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=20251203205427.GB741246@yaz-khff2.amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=ariadne@ariadne.space \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steven@uplinklabs.net \
    --cc=x86@vger.kernel.org \
    /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®