mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten
@ 2024-10-04 23:59 Mohammed Anees
  2024-10-09  8:22 ` Pierre-Eric Pelloux-Prayer
  0 siblings, 1 reply; 4+ messages in thread
From: Mohammed Anees @ 2024-10-04 23:59 UTC (permalink / raw)
  To: amd-gfx, dri-devel, linux-kernel
  Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
	Simona Vetter, Srinivasan Shanmugam, David Wu, Felix Kuehling,
	Mohammed Anees

Before this patch, if multiple BO_HANDLES chunks were submitted,
the error -EINVAL would be correctly set but could be overwritten
by the return value from amdgpu_cs_p1_bo_handles(). This patch
ensures that once an error condition is detected, the function
returns immediately, avoiding the overwriting of the error code.

Signed-off-by: Mohammed Anees <pvmohammedanees2003@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 1e475eb01417..543db0df9a31 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -266,8 +266,9 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
 			/* Only a single BO list is allowed to simplify handling. */
 			if (p->bo_list)
 				ret = -EINVAL;
+			else
+				ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
 
-			ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
 			if (ret)
 				goto free_partial_kdata;
 			break;
-- 
2.46.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten
  2024-10-04 23:59 [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten Mohammed Anees
@ 2024-10-09  8:22 ` Pierre-Eric Pelloux-Prayer
  2024-10-09 10:34   ` Christian König
  2024-10-09 12:30   ` Mohammed Anees
  0 siblings, 2 replies; 4+ messages in thread
From: Pierre-Eric Pelloux-Prayer @ 2024-10-09  8:22 UTC (permalink / raw)
  To: Mohammed Anees, amd-gfx, dri-devel, linux-kernel
  Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
	Simona Vetter, Srinivasan Shanmugam, David Wu, Felix Kuehling

Hi,

Le 05/10/2024 à 01:59, Mohammed Anees a écrit :
> Before this patch, if multiple BO_HANDLES chunks were submitted,
> the error -EINVAL would be correctly set but could be overwritten
> by the return value from amdgpu_cs_p1_bo_handles(). This patch
> ensures that once an error condition is detected, the function
> returns immediately, avoiding the overwriting of the error code.
> 
> Signed-off-by: Mohammed Anees <pvmohammedanees2003@gmail.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 1e475eb01417..543db0df9a31 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -266,8 +266,9 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
>   			/* Only a single BO list is allowed to simplify handling. */
>   			if (p->bo_list)
>   				ret = -EINVAL;
> +			else
> +				ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
>   
> -			ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);

My bad, I've merged the wrong version of the patch.

That being said, I think it'd be nicer to follow the same pattern as the other checks and do:

    if (p->bo_list)
       goto free_partial_kdata;

Since "ret" is initialized to -EINVAL already.

Also can you add a reference to the broken commit in the commit message?
Something like:

Fixes: fec5f8e8c6bcf83 ("drm/amdgpu: disallow multiple BO_HANDLES chunks in one submit")

Thanks,
Pierre-Eric

>   			if (ret)
>   				goto free_partial_kdata;
>   			break;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten
  2024-10-09  8:22 ` Pierre-Eric Pelloux-Prayer
@ 2024-10-09 10:34   ` Christian König
  2024-10-09 12:30   ` Mohammed Anees
  1 sibling, 0 replies; 4+ messages in thread
From: Christian König @ 2024-10-09 10:34 UTC (permalink / raw)
  To: Pierre-Eric Pelloux-Prayer, Mohammed Anees, amd-gfx, dri-devel,
	linux-kernel
  Cc: Alex Deucher, Xinhui Pan, David Airlie, Simona Vetter,
	Srinivasan Shanmugam, David Wu, Felix Kuehling

Am 09.10.24 um 10:22 schrieb Pierre-Eric Pelloux-Prayer:
> Hi,
>
> Le 05/10/2024 à 01:59, Mohammed Anees a écrit :
>> Before this patch, if multiple BO_HANDLES chunks were submitted,
>> the error -EINVAL would be correctly set but could be overwritten
>> by the return value from amdgpu_cs_p1_bo_handles(). This patch
>> ensures that once an error condition is detected, the function
>> returns immediately, avoiding the overwriting of the error code.
>>
>> Signed-off-by: Mohammed Anees <pvmohammedanees2003@gmail.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> index 1e475eb01417..543db0df9a31 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> @@ -266,8 +266,9 @@ static int amdgpu_cs_pass1(struct 
>> amdgpu_cs_parser *p,
>>               /* Only a single BO list is allowed to simplify 
>> handling. */
>>               if (p->bo_list)
>>                   ret = -EINVAL;
>> +            else
>> +                ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
>>   -            ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
>
> My bad, I've merged the wrong version of the patch.
>
> That being said, I think it'd be nicer to follow the same pattern as 
> the other checks and do:
>
>    if (p->bo_list)
>       goto free_partial_kdata;
>
> Since "ret" is initialized to -EINVAL already.
>
> Also can you add a reference to the broken commit in the commit message?
> Something like:
>
> Fixes: fec5f8e8c6bcf83 ("drm/amdgpu: disallow multiple BO_HANDLES 
> chunks in one submit")

Yeah agree with Pierre-Eric and also please add the same CC stable tag 
the original patch had so that it gets backported ASAP.

Thanks,
Christian.

>
> Thanks,
> Pierre-Eric
>
>>               if (ret)
>>                   goto free_partial_kdata;
>>               break;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten
  2024-10-09  8:22 ` Pierre-Eric Pelloux-Prayer
  2024-10-09 10:34   ` Christian König
@ 2024-10-09 12:30   ` Mohammed Anees
  1 sibling, 0 replies; 4+ messages in thread
From: Mohammed Anees @ 2024-10-09 12:30 UTC (permalink / raw)
  To: pierre-eric
  Cc: David.Wu3, Xinhui.Pan, airlied, alexander.deucher, amd-gfx,
	christian.koenig, dri-devel, felix.kuehling, linux-kernel,
	pvmohammedanees2003, simona, srinivasan.shanmugam

Hi,

I have sent the v2 Patch reflecting these changes along with
the Cc tag as suggested by Christian.

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-09 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-04 23:59 [PATCH] drm/amdgpu: prevent BO_HANDLES error from being overwritten Mohammed Anees
2024-10-09  8:22 ` Pierre-Eric Pelloux-Prayer
2024-10-09 10:34   ` Christian König
2024-10-09 12:30   ` Mohammed Anees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®