diff mbox

drm/ttm: fix ttm_bo_add_ttm(user) failure path

Message ID 20110822211757.GB3098@joi.lan (mailing list archive)
State Accepted
Headers show

Commit Message

Marcin Ĺšlusarz Aug. 22, 2011, 9:17 p.m. UTC
ttm_tt_destroy kfrees passed object, so we need to nullify
a reference to it.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: stable@kernel.org
---
 drivers/gpu/drm/ttm/ttm_bo.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Thomas Hellstrom Aug. 23, 2011, 6:13 a.m. UTC | #1
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>

On 08/22/2011 11:17 PM, Marcin Slusarz wrote:
> ttm_tt_destroy kfrees passed object, so we need to nullify
> a reference to it.
>
> Signed-off-by: Marcin Slusarz<marcin.slusarz@gmail.com>
> Cc: stable@kernel.org
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 251df77..2e8f929 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -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");
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 251df77..2e8f929 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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");