From: Jammy Zhou Date: Tue, 12 May 2015 15:17:19 +0000 (+0800) Subject: drm/amdgpu: do necessary NULL check X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4b095304ea7f73c178cd906df37185c0b9ad9a60;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git drm/amdgpu: do necessary NULL check Signed-off-by: Jammy Zhou Reviewed-by: Christian König --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index 855d56ac7115..21accbdd0a1a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c @@ -101,6 +101,9 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, unsigned i; int r = 0; + if (resv == NULL) + return -EINVAL; + /* always sync to the exclusive fence */ f = reservation_object_get_excl(resv); fence = f ? to_amdgpu_fence(f) : NULL; @@ -116,12 +119,12 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, for (i = 0; i < flist->shared_count; ++i) { f = rcu_dereference_protected(flist->shared[i], reservation_object_held(resv)); - fence = to_amdgpu_fence(f); + fence = f ? to_amdgpu_fence(f) : NULL; if (fence && fence->ring->adev == adev) { if (fence->owner != owner || fence->owner == AMDGPU_FENCE_OWNER_UNDEFINED) amdgpu_sync_fence(sync, fence); - } else { + } else if (f) { r = fence_wait(f, true); if (r) break;