]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amdgpu: Fix NULL ptr deref in amdgpu_device_cache_switch_state()
authorJohn Olender <john.olender@gmail.com>
Fri, 5 Sep 2025 10:11:28 +0000 (06:11 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Sep 2025 20:14:23 +0000 (16:14 -0400)
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: 1dd2fa0e00f1 ("drm/amdgpu: Save and restore switch state")
Link: https://lore.kernel.org/amd-gfx/38fe6513-f8a9-4669-8e86-89c54c465611@gmail.com/
Reviewed-by: Candice Li <candice.li@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Signed-off-by: John Olender <john.olender@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index bdfb80377e6a8d94af0312d4481e641c07c4311f..b20383021b5052f64f7f698c264ad68e54475bbd 100644 (file)
@@ -7161,7 +7161,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 */