* [PATCH v3] drm/amdgpu: clean up the amdgpu_cs_parser_bos
@ 2026-02-04 6:24 Sunil Khatri
2026-02-04 6:29 ` Khatri, Sunil
0 siblings, 1 reply; 2+ messages in thread
From: Sunil Khatri @ 2026-02-04 6:24 UTC (permalink / raw)
To: Alex Deucher, Christian König
Cc: amd-gfx, Sunil Khatri, kernel test robot, Dan Carpenter
In low memory conditions when kmalloc can fail and hence
we need to clean up the bo list 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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202602030017.7E0xShmH-lkp@intel.com/
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index d591dce0f3b3..b166bccecee3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -892,8 +892,10 @@ 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))
- return -ENOMEM;
+ if (unlikely(!e->range)) {
+ r = -ENOMEM;
+ goto out_free_user_pages;
+ }
r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
if (r)
@@ -998,6 +1000,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
amdgpu_hmm_range_free(e->range);
e->range = NULL;
}
+
+ amdgpu_bo_list_put(p->bo_list);
mutex_unlock(&p->bo_list->bo_list_mutex);
return r;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] drm/amdgpu: clean up the amdgpu_cs_parser_bos
2026-02-04 6:24 [PATCH v3] drm/amdgpu: clean up the amdgpu_cs_parser_bos Sunil Khatri
@ 2026-02-04 6:29 ` Khatri, Sunil
0 siblings, 0 replies; 2+ messages in thread
From: Khatri, Sunil @ 2026-02-04 6:29 UTC (permalink / raw)
To: Sunil Khatri, Alex Deucher, Christian König
Cc: amd-gfx, kernel test robot, Dan Carpenter
Ignore this patch version as v4 is pushed.
Regards
Sunil Khatri
On 04-02-2026 11:54 am, Sunil Khatri wrote:
> In low memory conditions when kmalloc can fail and hence
> we need to clean up the bo list 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 <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202602030017.7E0xShmH-lkp@intel.com/
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index d591dce0f3b3..b166bccecee3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -892,8 +892,10 @@ 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))
> - return -ENOMEM;
> + if (unlikely(!e->range)) {
> + r = -ENOMEM;
> + goto out_free_user_pages;
> + }
>
> r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
> if (r)
> @@ -998,6 +1000,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
> amdgpu_hmm_range_free(e->range);
> e->range = NULL;
> }
> +
> + amdgpu_bo_list_put(p->bo_list);
> mutex_unlock(&p->bo_list->bo_list_mutex);
> return r;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-04 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04 6:24 [PATCH v3] drm/amdgpu: clean up the amdgpu_cs_parser_bos Sunil Khatri
2026-02-04 6:29 ` Khatri, Sunil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox