drm/radeon: avoid potential null pointer access
authorGuchun Chen <guchun.chen@amd.com>
Tue, 30 Mar 2021 14:02:06 +0000 (22:02 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Apr 2021 20:49:46 +0000 (16:49 -0400)
Leverage the same logic from amdgpu_ttm_tt_unpin_userptr.

Signed-off-by: Guchun Chen <guchun.chen@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_ttm.c

index c84e128daff87c2b6c6ac3fa3c20a9f961abdf2f..cdb6d3efd07db6ca4f80f25970411b8db88714bb 100644 (file)
@@ -415,7 +415,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_device *bdev, struct ttm_tt *
                DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
        /* double check that we don't free the table twice */
-       if (!ttm->sg->sgl)
+       if (!ttm->sg || !ttm->sg->sgl)
                return;
 
        /* free the sg table and pages again */