Skip to contentSkip to conversation

drm/amdgpu: Using uninitialized value *size when calling amdgpu_vce_cs_reloc

PATCH In review Jesse Zhang 2 participants 2 messages Apr 24, 2024

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

PATCH v2 4/4 drm/amdgpu: Using uninitialized value *size when calling amdgpu_vce_cs_reloc

Initialize the size before calling amdgpu_vce_cs_reloc, such as case 0x03000001.
V2: To really improve the handling we would actually

    need to have a separate value of 0xffffffff.(Christian)
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1 -1
index 59acf424a078..1929de0db3a1 100644
@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
 	uint32_t destroyed = 0;
 	uint32_t created = 0;
 	uint32_t allocated = 0;
-	uint32_t tmp, handle = 0;
+	uint32_t tmp = 0xffffffff, handle = 0;
 	uint32_t *size = &tmp;
 	unsigned int idx;
 	int i, r = 0;
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Am 24.04.24 um 10:41 schrieb Jesse Zhang:

Quoted 14 lines

Initialize the size before calling amdgpu_vce_cs_reloc, such as case 0x03000001.
V2: To really improve the handling we would actually

     need to have a separate value of 0xffffffff.(Christian)
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0 -0
index 59acf424a078..1929de0db3a1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1 -1
@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
  	uint32_t destroyed = 0;
  	uint32_t created = 0;
  	uint32_t allocated = 0;
-	uint32_t tmp, handle = 0;
+	uint32_t tmp = 0xffffffff, handle = 0;

That's close, but what I meant was to have something like this instead:

uint32_t dummy = 0xffffffff; *size = &dummy.

Because tmp is overwritten by user values while parsing the command stream.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0 -0
  	uint32_t *size = &tmp;
  	unsigned int idx;
  	int i, r = 0;