Skip to contentSkip to conversation

drm/radeon: avoid potential null pointer access

PATCH In review Guchun Chen 2 participants 2 messages Mar 30, 2021

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

PATCH 1/1 drm/radeon: avoid potential null pointer access

Leverage the same logic from amdgpu_ttm_tt_unpin_userptr.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
index 37ac42d6740f..2a61cff325e4 100644
@@ -415,7 +415,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_device *bdev, struct ttm_tt *
 		DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
 	/* double check that we don't free the table twice */
-	if (!ttm->sg->sgl)
+	if (!ttm->sg || !ttm->sg->sgl)
 		return;
 
 	/* free the sg table and pages again */
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 30.03.21 um 16:04 schrieb Guchun Chen:

Quoted 3 lines

Leverage the same logic from amdgpu_ttm_tt_unpin_userptr.

Quoted 9 lines
---
  drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_ttm.c +0 -0
index 37ac42d6740f..2a61cff325e4 100644

drivers/gpu/drm/radeon/radeon_ttm.c static void radeon_ttm_tt_unpin_userptr(struct ttm_device *bdev, struct ttm_tt * · line 421

Quoted 8 lines
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
@@ -415,7 +415,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_device *bdev, struct ttm_tt *
  		DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
  	/* double check that we don't free the table twice */
-	if (!ttm->sg->sgl)
+	if (!ttm->sg || !ttm->sg->sgl)
  		return;
 
  	/* free the sg table and pages again */

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx