All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpu/host1x: remove useless if(ptr) check to kfree
@ 2022-04-13  6:39 Bernard Zhao
  2022-04-13  7:20 ` Mikko Perttunen
  0 siblings, 1 reply; 2+ messages in thread
From: Bernard Zhao @ 2022-04-13  6:39 UTC (permalink / raw)
  To: Thierry Reding, David Airlie, Daniel Vetter, dri-devel,
	linux-tegra, linux-kernel
  Cc: bernard, Bernard Zhao

This patch remove useless if(ptr) check to kfree.

Signed-off-by: Bernard Zhao <zhaojunkui2008@126.com>
---
 drivers/gpu/host1x/fence.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
index ecab72882192..05b36bfc8b74 100644
--- a/drivers/gpu/host1x/fence.c
+++ b/drivers/gpu/host1x/fence.c
@@ -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);
 }
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpu/host1x: remove useless if(ptr) check to kfree
  2022-04-13  6:39 [PATCH] gpu/host1x: remove useless if(ptr) check to kfree Bernard Zhao
@ 2022-04-13  7:20 ` Mikko Perttunen
  0 siblings, 0 replies; 2+ messages in thread
From: Mikko Perttunen @ 2022-04-13  7:20 UTC (permalink / raw)
  To: Bernard Zhao, Thierry Reding, David Airlie, Daniel Vetter,
	dri-devel, linux-tegra, linux-kernel
  Cc: bernard

On 4/13/22 09:39, Bernard Zhao wrote:
> This patch remove useless if(ptr) check to kfree.
> 
> Signed-off-by: Bernard Zhao <zhaojunkui2008@126.com>
> ---
>   drivers/gpu/host1x/fence.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
> index ecab72882192..05b36bfc8b74 100644
> --- a/drivers/gpu/host1x/fence.c
> +++ b/drivers/gpu/host1x/fence.c
> @@ -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 personally dislike leaving the NULL checks off with calls to kfree. 
With the NULL check there, while reading the code it is obvious that the 
intention is that the value can be either a valid pointer or NULL. IMHO 
with C's type system/conventions we need this kind of contextual 
information to understand the code easily and avoid bugs.

Mikko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-13  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  6:39 [PATCH] gpu/host1x: remove useless if(ptr) check to kfree Bernard Zhao
2022-04-13  7:20 ` Mikko Perttunen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.