Skip to contentSkip to conversation

drm/amdgpu: clean up the amdgpu_cs_parser_bos

PATCH Superseded Sunil Khatri 1 participant 1 message Feb 3

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: clean up the amdgpu_cs_parser_bos

In low memory conditions when kmalloc can fail and hence we need to clean up the memory and unlock the mutex for clean exit.

Fixes 737da5363cc0 ("drm/amdgpu: update the functions to use amdgpu version of hmm")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -1
index d591dce0f3b3..3086b37aec99 100644
@@ -892,8 +892,11 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 		struct amdgpu_bo *bo = e->bo;
 
 		e->range = amdgpu_hmm_range_alloc(NULL);
-		if (unlikely(!e->range))
+		if (unlikely(!e->range)) {
+			mutex_unlock(&p->bo_list->bo_list_mutex);
+			amdgpu_bo_list_put(p->bo_list);
 			return -ENOMEM;
+		}
 
 		r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
 		if (r)
Signature · 1 line
2.34.1