Skip to contentSkip to conversation

gpu: host1x: Remove redundant null checks before kfree

PATCH In review [email protected] 2 participants 2 messages Dec 1, 2022

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

PATCH 1/1 gpu: host1x: Remove redundant null checks before kfree

From: Yushan Zhou <[email protected]>

Fix the following coccicheck warning:
./drivers/gpu/host1x/fence.c:97:2-7: WARNING:
NULL check before some freeing functions is not needed.

---
 drivers/gpu/host1x/fence.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/host1x/fence.c +1 -2
index ecab72882192..05b36bfc8b74 100644
@@ -93,8 +93,7 @@ static void host1x_syncpt_fence_release(struct dma_fence *f)
 {
 	struct host1x_syncpt_fence *sf = to_host1x_fence(f);
 
-	if (sf->waiter)
-		kfree(sf->waiter);
+	kfree(sf->waiter);
 
 	dma_fence_free(f);
 }
Signature · 1 line
2.27.0
#1 lore raw
Quoted 16 lines · On 12/1/22 03:55, [email protected] wrote:

From: Yushan Zhou <[email protected]>

Fix the following coccicheck warning:
./drivers/gpu/host1x/fence.c:97:2-7: WARNING:
NULL check before some freeing functions is not needed.

---
  drivers/gpu/host1x/fence.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/host1x/fence.c +0 -0
index ecab72882192..05b36bfc8b74 100644

drivers/gpu/host1x/fence.c static void host1x_syncpt_fence_release(struct dma_fence *f) · line 99

Quoted 9 lines
drivers/gpu/host1x/fence.c +1 -2
@@ -93,8 +93,7 @@ static void host1x_syncpt_fence_release(struct dma_fence *f)
  {
  	struct host1x_syncpt_fence *sf = to_host1x_fence(f);
 
-	if (sf->waiter)
-		kfree(sf->waiter);
+	kfree(sf->waiter);
 
  	dma_fence_free(f);
  }

I disagree with this coccinelle rule; I think it obfuscates from the reader the fact that the pointer could be NULL.

Mikko