Skip to contentSkip to conversation

drm/ttm: fix uninit ptr deref in range manager alloc error path

PATCH In review Robert Beckett 2 participants 2 messages Mar 16, 2022 – Mar 17, 2022

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

PATCH 1/1 drm/ttm: fix uninit ptr deref in range manager alloc error path

ttm_range_man_alloc would try to ttm_resource_fini the res pointer before it is allocated.

Fixes de3688e469b0 (drm/ttm: add ttm_resource_fini v2)
---
 drivers/gpu/drm/ttm/ttm_range_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_range_manager.c +1 -1
index 5662627bb933..1b4d8ca52f68 100644
@@ -89,7 +89,7 @@ static int ttm_range_man_alloc(struct ttm_resource_manager *man,
 	spin_unlock(&rman->lock);
 
 	if (unlikely(ret)) {
-		ttm_resource_fini(man, *res);
+		ttm_resource_fini(man, &node->base);
 		kfree(node);
 		return ret;
 	}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Am 16.03.22 um 20:50 schrieb Robert Beckett:

Quoted 6 lines

ttm_range_man_alloc would try to ttm_resource_fini the res pointer before it is allocated.

Fixes de3688e469b0 (drm/ttm: add ttm_resource_fini v2)

Good catch, going to push that to drm-misc-fixes.

Quoted 17 lines
---
  drivers/gpu/drm/ttm/ttm_range_manager.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_range_manager.c +1 -1
index 5662627bb933..1b4d8ca52f68 100644
@@ -89,7 +89,7 @@ static int ttm_range_man_alloc(struct ttm_resource_manager *man,
  	spin_unlock(&rman->lock);
 
  	if (unlikely(ret)) {
-		ttm_resource_fini(man, *res);
+		ttm_resource_fini(man, &node->base);
  		kfree(node);
  		return ret;
  	}