drm/amdgpu: add missing NULL check
Subsystems (2)
PATCH 1/1 drm/amdgpu: add missing NULL check
bo->tbo.resource can easily be NULL here.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1 -1
@@ -252,7 +252,7 @@ static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct amdgpu_res_cursor cursor; -if (bo->tbo.resource->mem_type !=TTM_PL_VRAM ) +if (!bo->tbo.resource || bo->tbo.resource->mem_type !=TTM_PL_VRAM )return false;amdgpu_res_first (bo->tbo.resource,0 ,amdgpu_bo_size (bo), &cursor);
Signature · 1 line
2.34.1
Quoted 4 lines · Christian König
bo->tbo.resourcecan easily be NULL here.Signed-off-by Christian König <[email protected]>
Add a link to the bug report? With that:
Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-2@@ -252,7 +252,7 @@ static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct amdgpu_res_cursor cursor; -if (bo->tbo.resource->mem_type !=TTM_PL_VRAM ) +if (!bo->tbo.resource || bo->tbo.resource->mem_type !=TTM_PL_VRAM )return false;amdgpu_res_first (bo->tbo.resource,0 ,amdgpu_bo_size (bo), &cursor); --2.34.1
Am 06.10.23 um 16:41 schrieb Alex Deucher:
Quoted 6 lines
Quoted 3 lines · Christian König
bo->tbo.resourcecan easily be NULL here.Signed-off-by Christian König <[email protected]>Add a link to the bug report?
Ah, crap. Forgotten to add the link before pushing that. But I've added a CC stable.
Apart from that I suspect that this doesn't fix the real issue here, it just mitigates the problem.
For some reason we can't allocate OA resources, but also doesn't fail and instead keep working with an empty BO.
Regards,
Christian.
Quoted 23 lines
With that:
Reviewed-by Alex Deucher <[email protected]>Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-2@@ -252,7 +252,7 @@ static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct amdgpu_res_cursor cursor; -if (bo->tbo.resource->mem_type !=TTM_PL_VRAM ) +if (!bo->tbo.resource || bo->tbo.resource->mem_type !=TTM_PL_VRAM )return false;amdgpu_res_first (bo->tbo.resource,0 ,amdgpu_bo_size (bo), &cursor); --2.34.1
I can confirm this patch fixes the kernel crash I reported.
But as discussed with Christian, we should find the root cause.
Quoted 20 lines · Christian König
bo->tbo.resourcecan easily be NULL here.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-1@@ -252,7 +252,7 @@ static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct amdgpu_res_cursor cursor; -if (bo->tbo.resource->mem_type !=TTM_PL_VRAM ) +if (!bo->tbo.resource || bo->tbo.resource->mem_type !=TTM_PL_VRAM )return false;amdgpu_res_first (bo->tbo.resource,0 ,amdgpu_bo_size (bo), &cursor);