The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Prike Liang <Prike.Liang@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Shashank Sharma <shashank.sharma@amd.com>,
	Arvind Yadav <Arvind.Yadav@amd.com>,
	Sunil Khatri <sunil.khatri@amd.com>,
	"Jesse.Zhang" <Jesse.Zhang@amd.com>,
	Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] drm/amdgpu/userq: Fix error codes in mes_userq_mqd_create()
Date: Thu, 18 Sep 2025 11:57:20 +0200	[thread overview]
Message-ID: <111d7bd7-57bb-4873-a62f-876128281572@amd.com> (raw)
In-Reply-To: <aMvVAsrczM9W2S7P@stanley.mountain>



On 18.09.25 11:46, Dan Carpenter wrote:
> Return the error code if amdgpu_userq_input_va_validate() fails.  Don't
> return success.
> 
> Fixes: 9e46b8bb0539 ("drm/amdgpu: validate userq buffer virtual address and size")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index 2db9b2c63693..775b0bd5d6c4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -298,8 +298,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
>  			goto free_mqd;
>  		}
>  
> -		if (amdgpu_userq_input_va_validate(queue->vm, compute_mqd->eop_va,
> -		    max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)))
> +		r = amdgpu_userq_input_va_validate(queue->vm, compute_mqd->eop_va,
> +		    max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE));

That code is nonsense to begin with, AMDGPU_GPU_PAGE_SIZE is always <= PAGE_SIZE or otherwise the whole driver stack doesn't work.

We should probably drop the max_t() as well.

Regards,
Christian.

> +		if (r)
>  			goto free_mqd;
>  
>  		userq_props->eop_gpu_addr = compute_mqd->eop_va;
> @@ -330,8 +331,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
>  		userq_props->tmz_queue =
>  			mqd_user->flags & AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE;
>  
> -		if (amdgpu_userq_input_va_validate(queue->vm, mqd_gfx_v11->shadow_va,
> -		    shadow_info.shadow_size))
> +		r = amdgpu_userq_input_va_validate(queue->vm, mqd_gfx_v11->shadow_va,
> +		    shadow_info.shadow_size);
> +		if (r)
>  			goto free_mqd;
>  
>  		kfree(mqd_gfx_v11);
> @@ -351,8 +353,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
>  			goto free_mqd;
>  		}
>  
> -		if (amdgpu_userq_input_va_validate(queue->vm, mqd_sdma_v11->csa_va,
> -		    shadow_info.csa_size))
> +		r = amdgpu_userq_input_va_validate(queue->vm, mqd_sdma_v11->csa_va,
> +		    shadow_info.csa_size);
> +		if (r)
>  			goto free_mqd;
>  
>  		userq_props->csa_addr = mqd_sdma_v11->csa_va;


  reply	other threads:[~2025-09-18  9:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  9:46 [PATCH next] drm/amdgpu/userq: Fix error codes in mes_userq_mqd_create() Dan Carpenter
2025-09-18  9:57 ` Christian König [this message]
2025-09-19  2:50   ` Liang, Prike
2025-09-29  6:15     ` Liang, Prike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=111d7bd7-57bb-4873-a62f-876128281572@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=Arvind.Yadav@amd.com \
    --cc=Jesse.Zhang@amd.com \
    --cc=Prike.Liang@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shashank.sharma@amd.com \
    --cc=simona@ffwll.ch \
    --cc=sunil.khatri@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox