[PATCH] gfs2: Remove unnecessary NULL check before free_percpu()

Chen Ni posted 1 patch 8 months ago
fs/gfs2/ops_fstype.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] gfs2: Remove unnecessary NULL check before free_percpu()
Posted by Chen Ni 8 months ago
free_percpu() checks for NULL pointers internally.
Remove unneeded NULL check here.

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

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index ea5b3c5c6e1c..8f9bb6677db7 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -64,8 +64,7 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
 
 void free_sbd(struct gfs2_sbd *sdp)
 {
-	if (sdp->sd_lkstats)
-		free_percpu(sdp->sd_lkstats);
+	free_percpu(sdp->sd_lkstats);
 	kfree(sdp);
 }
 
-- 
2.25.1
Re: [PATCH] gfs2: Remove unnecessary NULL check before free_percpu()
Posted by Andreas Gruenbacher 8 months ago
On Thu, Apr 17, 2025 at 10:45 AM Chen Ni <nichen@iscas.ac.cn> wrote:
> free_percpu() checks for NULL pointers internally.
> Remove unneeded NULL check here.
>
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  fs/gfs2/ops_fstype.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index ea5b3c5c6e1c..8f9bb6677db7 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -64,8 +64,7 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
>
>  void free_sbd(struct gfs2_sbd *sdp)
>  {
> -       if (sdp->sd_lkstats)
> -               free_percpu(sdp->sd_lkstats);
> +       free_percpu(sdp->sd_lkstats);
>         kfree(sdp);
>  }
>
> --
> 2.25.1
>

Applied, thanks.

Andreas