Skip to contentSkip to conversation

drm/radeon: check bo_va->bo is non-NULL before using it

PATCH In review Pierre-Eric Pelloux-Prayer 4 participants 5 messages Jun 25, 2024 – Jun 28, 2024

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

PATCH v2 1/1 drm/radeon: check bo_va->bo is non-NULL before using it

The call to radeon_vm_clear_freed might clear bo_va->bo, so we have to check it before dereferencing it.

---
 drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -1
index 3fec3acdaf28..27225d1fe8d2 100644
@@ -641,7 +641,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
 	if (r)
 		goto error_unlock;
 
-	if (bo_va->it.start)
+	if (bo_va->it.start && bo_va->bo)
 		r = radeon_vm_bo_update(rdev, bo_va, bo_va->bo->tbo.resource);
 
 error_unlock:
Signature · 1 line
2.45.2
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Pierre-Eric Pelloux-Prayer

The call to radeon_vm_clear_freed might clear bo_va->bo, so we have to check it before dereferencing it.

Quoted 20 lines
---
 drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -2
index 3fec3acdaf28..27225d1fe8d2 100644
@@ -641,7 +641,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
        if (r)
                goto error_unlock;
 
-       if (bo_va->it.start)
+       if (bo_va->it.start && bo_va->bo)
                r = radeon_vm_bo_update(rdev, bo_va, bo_va->bo->tbo.resource);
 
 error_unlock:
--

2.45.2

maintainer
#2 lore raw

Am 25.06.24 um 19:44 schrieb Alex Deucher:

Quoted 7 lines
Quoted 4 lines · Pierre-Eric Pelloux-Prayer

The call to radeon_vm_clear_freed might clear bo_va->bo, so we have to check it before dereferencing it.

Should I push this to drm-misc-fixes or should Pierre push it to amd-staging-drm-next?

Might take some minor work from you when you start to handle radeon change as well.

Regards,
Christian.

Quoted 21 lines
Quoted 21 lines
---
  drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -2
index 3fec3acdaf28..27225d1fe8d2 100644
@@ -641,7 +641,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
         if (r)
                 goto error_unlock;
 
-       if (bo_va->it.start)
+       if (bo_va->it.start && bo_va->bo)
                 r = radeon_vm_bo_update(rdev, bo_va, bo_va->bo->tbo.resource);
 
  error_unlock:
--

2.45.2

#3 lore raw
Quoted 7 lines · Christian König

Am 25.06.24 um 19:44 schrieb Alex Deucher:

Quoted 5 lines
Quoted 3 lines · Pierre-Eric Pelloux-Prayer

The call to radeon_vm_clear_freed might clear bo_va->bo, so we have to check it before dereferencing it.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Should I push this to drm-misc-fixes or should Pierre push it to amd-staging-drm-next?

Might take some minor work from you when you start to handle radeon change as well.

Does this depend on anything in drm-misc? Otherwise, I can just take it via the standard channels. I already handle radeon patches via the amd tree.

Alex

Quoted 26 lines

Regards,
Christian.

Quoted 21 lines
Quoted 21 lines
---
  drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -2
index 3fec3acdaf28..27225d1fe8d2 100644
@@ -641,7 +641,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
         if (r)
                 goto error_unlock;
 
-       if (bo_va->it.start)
+       if (bo_va->it.start && bo_va->bo)
                 r = radeon_vm_bo_update(rdev, bo_va, bo_va->bo->tbo.resource);
 
  error_unlock:
--

2.45.2

#4 lore raw

Le 26/06/2024 à 15:59, Alex Deucher a écrit :

Quoted 15 lines
Quoted 13 lines · Christian König

Am 25.06.24 um 19:44 schrieb Alex Deucher:

Quoted 7 lines
Quoted 4 lines · Pierre-Eric Pelloux-Prayer

The call to radeon_vm_clear_freed might clear bo_va->bo, so we have to check it before dereferencing it.

Should I push this to drm-misc-fixes or should Pierre push it to amd-staging-drm-next?

Quoted 6 lines
Quoted 2 lines

Might take some minor work from you when you start to handle radeon change as well.

Does this depend on anything in drm-misc? Otherwise, I can just take it via the standard channels. I already handle radeon patches via the amd tree.

No it doesn't depend on anything in drm-misc. I'll push it to amd-staging-drm-next.

Pierre-Eric

Quoted 29 lines

Alex

Quoted 26 lines

Regards,
Christian.

Quoted 21 lines
Quoted 21 lines
---
   drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -2
index 3fec3acdaf28..27225d1fe8d2 100644
@@ -641,7 +641,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
          if (r)
                  goto error_unlock;
 
-       if (bo_va->it.start)
+       if (bo_va->it.start && bo_va->bo)
                  r = radeon_vm_bo_update(rdev, bo_va, bo_va->bo->tbo.resource);
 
   error_unlock:
--

2.45.2