Skip to contentSkip to conversation

drm/radeon/vm: don't attempt to update ptes if ib allocation fails

PATCH In review Alex Deucher 2 participants 2 messages Nov 13, 2013 – Nov 14, 2013

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

PATCH 1/1 drm/radeon/vm: don't attempt to update ptes if ib allocation fails

If we fail to allocate an indirect buffer (ib) when updating the ptes, return an error instead of trying to use the ib. Avoids a null pointer dereference.

Bug:
https://bugzilla.kernel.org/show_bug.cgi?id=58621

---
 drivers/gpu/drm/radeon/radeon_gart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_gart.c +2 -0
index cd7489b..3044e50 100644
@@ -1209,6 +1209,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
 		return -ENOMEM;
 
 	r = radeon_ib_get(rdev, R600_RING_TYPE_DMA_INDEX, &ib, NULL, ndw * 4);
+	if (r)
+		return r;
 	ib.length_dw = 0;
 
 	r = radeon_vm_update_pdes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

Am 13.11.2013 21:29, schrieb Alex Deucher:

Quoted 9 lines

If we fail to allocate an indirect buffer (ib) when updating the ptes, return an error instead of trying to use the ib. Avoids a null pointer dereference.

Bug:
https://bugzilla.kernel.org/show_bug.cgi?id=58621

I'm getting old. I've seen that as well while working on the VM page table init, but forgotten to fix it...

Quoted 17 lines
---
  drivers/gpu/drm/radeon/radeon_gart.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_gart.c +2 -0
index cd7489b..3044e50 100644
@@ -1209,6 +1209,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
  		return -ENOMEM;
 
  	r = radeon_ib_get(rdev, R600_RING_TYPE_DMA_INDEX, &ib, NULL, ndw * 4);
+	if (r)
+		return r;
  	ib.length_dw = 0;
 
  	r = radeon_vm_update_pdes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset);