[PATCH 2/2] drm/amdgpu: raise error on incorrect mem_type

Nirmoy Das nirmoy.das at amd.com
Fri Jun 25 17:28:04 UTC 2021


Be more defensive and raise error on wrong mem_type
argument in amdgpu_gtt_mgr_has_gart_addr().

Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 543000304a1c..0b0fa87b115c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -107,8 +107,12 @@ const struct attribute_group amdgpu_gtt_mgr_attr_group = {
  */
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *res)
 {
-	struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(res);
+	struct amdgpu_gtt_node *node;
+
+	if (WARN_ON(res->mem_type != TTM_PL_TT))
+		return false;
 
+	node = to_amdgpu_gtt_node(res);
 	return drm_mm_node_allocated(&node->base.mm_nodes[0]);
 }
 
-- 
2.32.0



More information about the amd-gfx mailing list