Whamcloud - gitweb
LU-18141 osd: don't check for NULL before free'ing 44/56044/2
authorTimothy Day <timday@amazon.com>
Wed, 14 Aug 2024 04:58:01 +0000 (00:58 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 22:07:49 +0000 (22:07 +0000)
The common free'ing macros already check for NULL,
so we don't need to explicitly check this beforehand.

The patch has been generated with the coccinelle script below.

@@
expression E;
@@
- if (E != NULL)
(
  OBD_FREE_PTR(E);
|
  OBD_FREE(E, ...);
|
  LIBCFS_FREE(E, ...);
|
  CFS_FREE_PTR(E);
|
  CFS_FREE_PTR_ARRAY(E, ...);
)

Test-Parameters: trivial
Test-Parameters: trivial fstype=zfs
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I62d78961192f00faf83f9f3fee3c4bf5b8006863
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56044
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_oi.c

index 154a717..9723830 100644 (file)
@@ -1027,8 +1027,7 @@ struct osd_obj_seq *osd_seq_load(struct osd_thread_info *info,
 cleanup:
        mutex_unlock(&map->om_dir_init_mutex);
        if (rc != 0) {
-               if (osd_seq != NULL)
-                       OBD_FREE_PTR(osd_seq);
+               OBD_FREE_PTR(osd_seq);
                RETURN(ERR_PTR(rc));
        }
 
index 78d5167..b19439d 100644 (file)
@@ -8146,8 +8146,7 @@ static void osd_key_fini(const struct lu_context *ctx,
                info->oti_ins_cache = NULL;
                info->oti_ins_cache_size = 0;
        }
-       if (info->oti_lookup_cache)
-               OBD_FREE_PTR(info->oti_lookup_cache);
+       OBD_FREE_PTR(info->oti_lookup_cache);
        OBD_FREE_PTR(info);
 }
 
index 6396dbb..9e4fa8b 100644 (file)
@@ -462,8 +462,7 @@ out:
                if (osd_seq != NULL && osd_seq->os_compat_dirs != NULL)
                        OBD_FREE_PTR_ARRAY(osd_seq->os_compat_dirs,
                                           osd_seq->os_subdir_count);
-               if (osd_seq != NULL)
-                       OBD_FREE_PTR(osd_seq);
+               OBD_FREE_PTR(osd_seq);
                osd_seq = ERR_PTR(rc);
        }
        RETURN(osd_seq);