diff mbox series

xfs: remove unnecessary NULL check before kvfree()

Message ID 20250311071114.1037911-1-nichen@iscas.ac.cn (mailing list archive)
State New
Headers show
Series xfs: remove unnecessary NULL check before kvfree() | expand

Commit Message

Chen Ni March 11, 2025, 7:11 a.m. UTC
Remove unnecessary NULL check before kvfree() reported by
Coccinelle/coccicheck and the semantic patch at
scripts/coccinelle/free/ifnullfree.cocci.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 fs/xfs/xfs_rtalloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Darrick J. Wong March 11, 2025, 4:01 p.m. UTC | #1
On Tue, Mar 11, 2025 at 03:11:14PM +0800, Chen Ni wrote:
> Remove unnecessary NULL check before kvfree() reported by
> Coccinelle/coccicheck and the semantic patch at
> scripts/coccinelle/free/ifnullfree.cocci.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>

Probably fine, though the line numbers have moved around a lot in
for-next...

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_rtalloc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 57bef567e011..9688e8ca6915 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1144,8 +1144,7 @@ xfs_growfs_rtg(
>  			goto out_error;
>  	}
>  
> -	if (old_rsum_cache)
> -		kvfree(old_rsum_cache);
> +	kvfree(old_rsum_cache);
>  	xfs_rtgroup_rele(rtg);
>  	return 0;
>  
> -- 
> 2.25.1
> 
>
Carlos Maiolino March 12, 2025, 9:14 a.m. UTC | #2
On Tue, Mar 11, 2025 at 03:11:14PM +0800, Chen Ni wrote:
> Remove unnecessary NULL check before kvfree() reported by
> Coccinelle/coccicheck and the semantic patch at
> scripts/coccinelle/free/ifnullfree.cocci.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>

Looks fine, please rebase it on top of for-next and send a V2.

Once rebased, feel free to include:
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

Adding Christoph to this as he cares a lot about this code.


> ---
>  fs/xfs/xfs_rtalloc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 57bef567e011..9688e8ca6915 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1144,8 +1144,7 @@ xfs_growfs_rtg(
>  			goto out_error;
>  	}
> 
> -	if (old_rsum_cache)
> -		kvfree(old_rsum_cache);
> +	kvfree(old_rsum_cache);
>  	xfs_rtgroup_rele(rtg);
>  	return 0;
> 
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 57bef567e011..9688e8ca6915 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1144,8 +1144,7 @@  xfs_growfs_rtg(
 			goto out_error;
 	}
 
-	if (old_rsum_cache)
-		kvfree(old_rsum_cache);
+	kvfree(old_rsum_cache);
 	xfs_rtgroup_rele(rtg);
 	return 0;