Skip to contentSkip to conversation

drm/ttm: fix ttm_bo_add_ttm(user) failure path

PATCH In review Marcin Slusarz 2 participants 2 messages Aug 22, 2011 – Aug 23, 2011

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

PATCH 1/1 drm/ttm: fix ttm_bo_add_ttm(user) failure path

ttm_tt_destroy kfrees passed object, so we need to nullify a reference to it.

---
 drivers/gpu/drm/ttm/ttm_bo.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index 251df77..2e8f929 100644
@@ -353,8 +353,10 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
 
 		ret = ttm_tt_set_user(bo->ttm, current,
 				      bo->buffer_start, bo->num_pages);
-		if (unlikely(ret != 0))
+		if (unlikely(ret != 0)) {
 			ttm_tt_destroy(bo->ttm);
+			bo->ttm = NULL;
+		}
 		break;
 	default:
 		printk(KERN_ERR TTM_PFX "Illegal buffer object type\n");
Signature · 1 line
1.7.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Marcin Slusarz

ttm_tt_destroy kfrees passed object, so we need to nullify a reference to it.

---
  drivers/gpu/drm/ttm/ttm_bo.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index 251df77..2e8f929 100644
@@ -353,8 +353,10 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
 
  		ret = ttm_tt_set_user(bo->ttm, current,
  				      bo->buffer_start, bo->num_pages);
-		if (unlikely(ret != 0))
+		if (unlikely(ret != 0)) {
  			ttm_tt_destroy(bo->ttm);
+			bo->ttm = NULL;
+		}
  		break;
  	default:
  		printk(KERN_ERR TTM_PFX "Illegal buffer object type\n");