Skip to contentSkip to conversation

drm/amdgpu: Fix null pointer issue in amdgpu_cs_wait_any_fence

PATCH In review Emily Deng 2 participants 2 messages Nov 9, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix null pointer issue in amdgpu_cs_wait_any_fence

The array[first] may be null when the fence has already been signaled.

BUG: SWDEV-136239
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +5 -2
index 354c874..182df08 100644
@@ -1502,8 +1502,11 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
 	memset(wait, 0, sizeof(*wait));
 	wait->out.status = (r > 0);
 	wait->out.first_signaled = first;
-	/* set return value 0 to indicate success */
-	r = array[first]->error;
+
+	if (array[first])
+		r = array[first]->error;
+	else
+		r = 0;
 
 err_free_fence_array:
 	for (i = 0; i < fence_count; i++)
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1510214382-6807-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 09.11.2017 um 08:59 schrieb Emily Deng:

Quoted 5 lines

The array[first] may be null when the fence has already been signaled.

BUG: SWDEV-136239
Quoted 12 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 354c874..182df08 100644
@@ -1502,8 +1502,11 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
  	memset(wait, 0, sizeof(*wait));
  	wait->out.status = (r > 0);
  	wait->out.first_signaled = first;

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev, · line 1512

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +5 -2
-	/* set return value 0 to indicate success */
-	r = array[first]->error;
+
+	if (array[first])
+		r = array[first]->error;
+	else
+		r = 0;
 
  err_free_fence_array:
  	for (i = 0; i < fence_count; i++)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx