drm/amdgpu: Fix null pointer issue in amdgpu_cs_wait_any_fence
authorEmily Deng <Emily.Deng@amd.com>
Thu, 9 Nov 2017 09:18:18 +0000 (17:18 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 9 Nov 2017 23:11:47 +0000 (18:11 -0500)
The array[first] may be null when the fence has already been signaled.

BUG: SWDEV-136239

Signed-off-by: Emily Deng <Emily.Deng@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index f7fceb6..146e05f 100644 (file)
@@ -1497,8 +1497,11 @@ out:
        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++)