Skip to contentSkip to conversation

drm/amdgpu: Remove unnecessary NULL check

PATCH In review Kent Russell 2 participants 2 messages Jan 2, 2025 – Jan 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Remove unnecessary NULL check

container_of cannot return NULL, so it is unnecessary to check for NULL after gem_to_amdgpu_bo, which just is a container_of call

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -4
index 7edccb675921..a1691ed717da 100644
@@ -196,10 +196,8 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
 	struct amdgpu_bo *aobj = gem_to_amdgpu_bo(gobj);
 
-	if (aobj) {
-		amdgpu_hmm_unregister(aobj);
-		ttm_bo_put(&aobj->tbo);
-	}
+	amdgpu_hmm_unregister(aobj);
+	ttm_bo_put(&aobj->tbo);
 }
 
 int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Kent Russell

container_of cannot return NULL, so it is unnecessary to check for NULL after gem_to_amdgpu_bo, which just is a container_of call

Quoted 21 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -4
index 7edccb675921..a1691ed717da 100644
@@ -196,10 +196,8 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
  {
  	struct amdgpu_bo *aobj = gem_to_amdgpu_bo(gobj);
 
-	if (aobj) {
-		amdgpu_hmm_unregister(aobj);
-		ttm_bo_put(&aobj->tbo);
-	}
+	amdgpu_hmm_unregister(aobj);
+	ttm_bo_put(&aobj->tbo);
  }
 
  int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,