On 03-02-2026 08:12 pm, Alex Deucher wrote:
On Tue, Feb 3, 2026 at 2:09 AM Sunil Khatri <[email protected]> wrote:
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")
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Sunil Khatri <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index d591dce0f3b3..831063971f71 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -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;
I think this should probably be:
r = -ENOMEM;
goto out_free_user_pages;
Agree, that's cleaner.

Also, does that error path need amdgpu_bo_list_put()?
Yes we do need that i guess.

we are doing amdgpu_bo_list_get or amdgpu_bo_list_create which needs to be cleaned if we failed here. Let me push a new patch based on those changes.

Regards
Sunil Khatri


Alex

+               }

                 r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
                 if (r)
--
2.34.1

Reply via email to