Skip to contentSkip to conversation

drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()

PATCH Applied John Olender 4 participants 4 messages Sep 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()

Kaveri has no upstream bridge, therefore parent is NULL.

$ lspci -PP
...
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics] (rev d4)

For comparison, Raphael:

$ lspci -PP
...
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Raphael/Granite Ridge Internal GPP Bridge to Bus [C:A]
...
00:08.1/0e:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Raphael (rev c5)
Fixes e5e203e0cd53 ("drm/amdgpu: Save and restore switch state")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 7783272a7930..ca58cde66446 100644
@@ -7148,7 +7148,7 @@ static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev)
 	struct pci_dev *parent = pci_upstream_bridge(adev->pdev);
 	int r;
 
-	if (parent->vendor != PCI_VENDOR_ID_ATI)
+	if (!parent || parent->vendor != PCI_VENDOR_ID_ATI)
 		return;
 
 	/* If already saved, return */

base-commit: 035edba1e204b302ae74269d4f09e355153a79ac

Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Thanks,
Candice

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of John Olender
Sent: Friday, September 5, 2025 6:11 PM
To: Wang, Yang(Kevin) <[email protected]>; Lazar, Lijo <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Sun, Ce(Overlord) <[email protected]>; John Olender <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()

Kaveri has no upstream bridge, therefore parent is NULL.

$ lspci -PP
...
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics] (rev d4)

For comparison, Raphael:

$ lspci -PP
...
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Raphael/Granite Ridge Internal GPP Bridge to Bus [C:A]
...
00:08.1/0e:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Raphael (rev c5)
Fixes e5e203e0cd53 ("drm/amdgpu: Save and restore switch state")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 7783272a7930..ca58cde66446 100644
@@ -7148,7 +7148,7 @@ static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev)
        struct pci_dev *parent = pci_upstream_bridge(adev->pdev);
        int r;
 
-       if (parent->vendor != PCI_VENDOR_ID_ATI)
+       if (!parent || parent->vendor != PCI_VENDOR_ID_ATI)
                return;
 
        /* If already saved, return */

base-commit: 035edba1e204b302ae74269d4f09e355153a79ac --
2.47.2

Reviewed-by on v1 1/1
#2 lore raw
In reply to John Olender

[AMD Official Use Only - AMD Internal Distribution Only]

Best Regards,
Kevin

-----Original Message-----
From: John Olender <[email protected]>
Sent: Friday, September 5, 2025 6:11 PM
To: Wang, Yang(Kevin) <[email protected]>; Lazar, Lijo <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Sun, Ce(Overlord) <[email protected]>; John Olender <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()

Kaveri has no upstream bridge, therefore parent is NULL.

$ lspci -PP
...
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics] (rev d4)

For comparison, Raphael:

$ lspci -PP
...
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Raphael/Granite Ridge Internal GPP Bridge to Bus [C:A] ...
00:08.1/0e:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Raphael (rev c5)
Fixes e5e203e0cd53 ("drm/amdgpu: Save and restore switch state")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 7783272a7930..ca58cde66446 100644
@@ -7148,7 +7148,7 @@ static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev)
        struct pci_dev *parent = pci_upstream_bridge(adev->pdev);
        int r;
 
-       if (parent->vendor != PCI_VENDOR_ID_ATI)
+       if (!parent || parent->vendor != PCI_VENDOR_ID_ATI)
                return;
 
        /* If already saved, return */

base-commit: 035edba1e204b302ae74269d4f09e355153a79ac --
2.47.2

Applied
#3 lore raw

Applied. Thanks!

Quoted 53 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Best Regards,
Kevin

-----Original Message-----
From: John Olender <[email protected]>
Sent: Friday, September 5, 2025 6:11 PM
To: Wang, Yang(Kevin) <[email protected]>; Lazar, Lijo <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Sun, Ce(Overlord) <[email protected]>; John Olender <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()

Kaveri has no upstream bridge, therefore parent is NULL.

$ lspci -PP
...
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics] (rev d4)

For comparison, Raphael:

$ lspci -PP
...
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Raphael/Granite Ridge Internal GPP Bridge to Bus [C:A] ...
00:08.1/0e:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Raphael (rev c5)
Fixes e5e203e0cd53 ("drm/amdgpu: Save and restore switch state")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 7783272a7930..ca58cde66446 100644
@@ -7148,7 +7148,7 @@ static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev)
        struct pci_dev *parent = pci_upstream_bridge(adev->pdev);
        int r;
 
-       if (parent->vendor != PCI_VENDOR_ID_ATI)
+       if (!parent || parent->vendor != PCI_VENDOR_ID_ATI)
                return;
 
        /* If already saved, return */

base-commit: 035edba1e204b302ae74269d4f09e355153a79ac --
2.47.2