Am 02.12.2016 um 10:11 schrieb Flora Cui: > Change-Id: I54d38957fe52c83bcee676da05bc480fcf1bc916 > Signed-off-by: Flora Cui <Flora.Cui at amd.com> > Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com> Nice catch, Reviewed-by: Christian König <christian.koenig at amd.com>. > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c > index 3c634f0..00f46b0 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c > @@ -164,8 +164,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, > spin_unlock(&mgr->lock); > > node = kzalloc(sizeof(*node), GFP_KERNEL); > - if (!node) > - return -ENOMEM; > + if (!node) { > + r = -ENOMEM; > + goto err_out; > + } > > node->start = AMDGPU_BO_INVALID_OFFSET; > node->size = mem->num_pages; > @@ -176,12 +178,20 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, > if (unlikely(r)) { > kfree(node); > mem->mm_node = NULL; > + r = 0; > + goto err_out; > } > } else { > mem->start = node->start; > } > > return 0; > +err_out: > + spin_lock(&mgr->lock); > + mgr->available += mem->num_pages; > + spin_unlock(&mgr->lock); > + > + return r; > } > > /**