public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] nfs: Remove unnecessary NULL check before kfree()
@ 2024-09-01 16:19 Thorsten Blum
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2024-09-01 16:19 UTC (permalink / raw)
  To: trondmy, anna; +Cc: linux-nfs, linux-kernel, Thorsten Blum, Benjamin Coddington

Since kfree() already checks if its argument is NULL, an additional
check before calling kfree() is unnecessary and can be removed.

Remove it and thus also the following Coccinelle/coccicheck warning
reported by ifnullfree.cocci:

  WARNING: NULL check before some freeing functions is not needed

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/nfs/read.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index a6103333b666..81bd1b9aba17 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -48,8 +48,7 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void)
 
 static void nfs_readhdr_free(struct nfs_pgio_header *rhdr)
 {
-	if (rhdr->res.scratch != NULL)
-		kfree(rhdr->res.scratch);
+	kfree(rhdr->res.scratch);
 	kmem_cache_free(nfs_rdata_cachep, rhdr);
 }
 
-- 
2.46.0


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

* [RESEND PATCH] nfs: Remove unnecessary NULL check before kfree()
@ 2024-09-10 10:42 Thorsten Blum
  2024-09-10 11:48 ` Jeff Layton
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2024-09-10 10:42 UTC (permalink / raw)
  To: trondmy, anna; +Cc: linux-nfs, linux-kernel, Thorsten Blum, Benjamin Coddington

Since kfree() already checks if its argument is NULL, an additional
check before calling kfree() is unnecessary and can be removed.

Remove it and thus also the following Coccinelle/coccicheck warning
reported by ifnullfree.cocci:

  WARNING: NULL check before some freeing functions is not needed

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/nfs/read.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index a6103333b666..81bd1b9aba17 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -48,8 +48,7 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void)
 
 static void nfs_readhdr_free(struct nfs_pgio_header *rhdr)
 {
-	if (rhdr->res.scratch != NULL)
-		kfree(rhdr->res.scratch);
+	kfree(rhdr->res.scratch);
 	kmem_cache_free(nfs_rdata_cachep, rhdr);
 }
 
-- 
2.46.0


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

* Re: [RESEND PATCH] nfs: Remove unnecessary NULL check before kfree()
  2024-09-10 10:42 [RESEND PATCH] nfs: Remove unnecessary NULL check before kfree() Thorsten Blum
@ 2024-09-10 11:48 ` Jeff Layton
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2024-09-10 11:48 UTC (permalink / raw)
  To: Thorsten Blum, trondmy, anna; +Cc: linux-nfs, linux-kernel, Benjamin Coddington

On Tue, 2024-09-10 at 12:42 +0200, Thorsten Blum wrote:
> Since kfree() already checks if its argument is NULL, an additional
> check before calling kfree() is unnecessary and can be removed.
> 
> Remove it and thus also the following Coccinelle/coccicheck warning
> reported by ifnullfree.cocci:
> 
>   WARNING: NULL check before some freeing functions is not needed
> 
> Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  fs/nfs/read.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/read.c b/fs/nfs/read.c
> index a6103333b666..81bd1b9aba17 100644
> --- a/fs/nfs/read.c
> +++ b/fs/nfs/read.c
> @@ -48,8 +48,7 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void)
>  
>  static void nfs_readhdr_free(struct nfs_pgio_header *rhdr)
>  {
> -	if (rhdr->res.scratch != NULL)
> -		kfree(rhdr->res.scratch);
> +	kfree(rhdr->res.scratch);
>  	kmem_cache_free(nfs_rdata_cachep, rhdr);
>  }
>  

Reviewed-by: Jeff Layton <jlayton@kernel.org>

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

end of thread, other threads:[~2024-09-10 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 10:42 [RESEND PATCH] nfs: Remove unnecessary NULL check before kfree() Thorsten Blum
2024-09-10 11:48 ` Jeff Layton
  -- strict thread matches above, loose matches on Subject: below --
2024-09-01 16:19 Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox