Skip to contentSkip to conversation

drm/amdgpu: Check if NBIO funcs are NULL in amdgpu_device_baco_exit

PATCH Applied Friedrich Vock 3 participants 3 messages May 14, 2024

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

PATCH 1/1 drm/amdgpu: Check if NBIO funcs are NULL in amdgpu_device_baco_exit

The special case for VM passthrough doesn't check adev->nbio.funcs before dereferencing it. If GPUs that don't have an NBIO block are passed through, this leads to a NULL pointer dereference on startup.

Fixes 1bece222eab ("drm/amdgpu: Clear doorbell interrupt status for Sienna Cichlid")
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 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 861ccff78af95..83c4533ee75c8 100644
@@ -6165,7 +6165,7 @@ int amdgpu_device_baco_exit(struct drm_device *dev)
 	    adev->nbio.funcs->enable_doorbell_interrupt)
 		adev->nbio.funcs->enable_doorbell_interrupt(adev, true);
 
-	if (amdgpu_passthrough(adev) &&
+	if (amdgpu_passthrough(adev) && adev->nbio.funcs &&
 	    adev->nbio.funcs->clear_doorbell_interrupt)
 		adev->nbio.funcs->clear_doorbell_interrupt(adev);
 

--
2.45.0

maintainer Acked-by on v1 1/1
#1 lore raw

Am 14.05.24 um 09:06 schrieb Friedrich Vock:

Quoted 5 lines

The special case for VM passthrough doesn't check adev->nbio.funcs before dereferencing it. If GPUs that don't have an NBIO block are passed through, this leads to a NULL pointer dereference on startup.

Quoted 24 lines
Fixes 1bece222eab ("drm/amdgpu: Clear doorbell interrupt status for Sienna Cichlid")
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
  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 -2
index 861ccff78af95..83c4533ee75c8 100644
@@ -6165,7 +6165,7 @@ int amdgpu_device_baco_exit(struct drm_device *dev)
  	    adev->nbio.funcs->enable_doorbell_interrupt)
  		adev->nbio.funcs->enable_doorbell_interrupt(adev, true);
 
-	if (amdgpu_passthrough(adev) &&
+	if (amdgpu_passthrough(adev) && adev->nbio.funcs &&
  	    adev->nbio.funcs->clear_doorbell_interrupt)
  		adev->nbio.funcs->clear_doorbell_interrupt(adev);
 
--

2.45.0

Applied
#2 lore raw

Applied. Thanks!

Quoted 35 lines · Christian König

Am 14.05.24 um 09:06 schrieb Friedrich Vock:

Quoted 5 lines

The special case for VM passthrough doesn't check adev->nbio.funcs before dereferencing it. If GPUs that don't have an NBIO block are passed through, this leads to a NULL pointer dereference on startup.

Quoted 24 lines
Fixes 1bece222eab ("drm/amdgpu: Clear doorbell interrupt status for Sienna Cichlid")
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
  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 -2
index 861ccff78af95..83c4533ee75c8 100644
@@ -6165,7 +6165,7 @@ int amdgpu_device_baco_exit(struct drm_device *dev)
          adev->nbio.funcs->enable_doorbell_interrupt)
              adev->nbio.funcs->enable_doorbell_interrupt(adev, true);
 
-     if (amdgpu_passthrough(adev) &&
+     if (amdgpu_passthrough(adev) && adev->nbio.funcs &&
          adev->nbio.funcs->clear_doorbell_interrupt)
              adev->nbio.funcs->clear_doorbell_interrupt(adev);
 
--

2.45.0