[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251203205427.GB741246@yaz-khff2.amd.com>
Date: Wed, 3 Dec 2025 15:54:27 -0500
From: Yazen Ghannam <yazen.ghannam@....com>
To: Steven Noonan <steven@...inklabs.net>
Cc: linux-kernel@...r.kernel.org, Ariadne Conill <ariadne@...adne.space>,
x86@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 2/2] x86/amd_node: fix null pointer dereference if
amd_smn_init failed
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@...inklabs.net>
> Signed-off-by: Ariadne Conill <ariadne@...adne.space>
> CC: Yazen Ghannam <yazen.ghannam@....com>
> CC: x86@...r.kernel.org
> CC: stable@...r.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
Powered by blists - more mailing lists