Skip to contentSkip to conversation

drm/amdgpu: prevent BO_HANDLES error from being overwritten

PATCH In review Mohammed Anees 3 participants 3 messages Oct 9, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: prevent BO_HANDLES error from being overwritten

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 if there are multiple BO_HANDLES, we stop.

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

---
v2:
- Switched to goto free_partial_kdata for error handling, following the existing pattern.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index 1e475eb01417..d891ab779ca7 100644
@@ -265,7 +265,7 @@ 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;
+				goto free_partial_kdata;
 
 			ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
 			if (ret)
Signature · 1 line
2.46.0
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 09.10.24 um 14:28 schrieb Mohammed Anees:

Quoted 8 lines

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 if there are multiple BO_HANDLES, we stop.

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

@Pierre-Eric can you pick that one up and push to amd-staging-drm-next?

Alex is currently on XDC and I'm a bit busy as well.

Thanks,
Christian.

Quoted 20 lines

---
v2:
- Switched to goto free_partial_kdata for error handling, following the existing pattern.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index 1e475eb01417..d891ab779ca7 100644
@@ -265,7 +265,7 @@ 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;
+				goto free_partial_kdata;
 
  			ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
  			if (ret)
#2 lore raw

Thanks for the updated patch, looks good to me.

Le 09/10/2024 à 14:31, Christian König a écrit :

Quoted 10 lines

Am 09.10.24 um 14:28 schrieb Mohammed Anees:

Quoted 8 lines

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 if there are multiple BO_HANDLES, we stop.

Fixes fec5f8e8c6bc ("drm/amdgpu: disallow multiple BO_HANDLES chunks in one submit")
Quoted 5 lines

@Pierre-Eric can you pick that one up and push to amd-staging-drm-next?

Alex is currently on XDC and I'm a bit busy as well.

Sure, will do.

Pierre-Eric

Quoted 22 lines

Thanks,
Christian.

Quoted 18 lines

---
v2:
- Switched to goto free_partial_kdata for error handling, following the existing pattern.
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index 1e475eb01417..d891ab779ca7 100644
@@ -265,7 +265,7 @@ 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;
+                goto free_partial_kdata;
               ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
               if (ret)