]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ocfs2: remove unnecessary null pointer check before kmem_cache_destroy()
authorpiaojun <piaojun@huawei.com>
Thu, 5 Apr 2018 23:18:52 +0000 (16:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Apr 2018 04:36:22 +0000 (21:36 -0700)
As kmem_cache_destroy() already handles null pointers, so we can remove
the conditional test entirely.

Link: http://lkml.kernel.org/r/5A9EB21D.3000209@huawei.com
Signed-off-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <ge.changwei@h3c.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/dlm/dlmlock.c
fs/ocfs2/dlm/dlmmaster.c
fs/ocfs2/super.c
fs/ocfs2/uptodate.c

index 66c2a491f68d8d5bc2956e59eb3018ab9113cf1d..74962315794e89e705b0653819a8251373cee0a5 100644 (file)
@@ -77,8 +77,7 @@ int dlm_init_lock_cache(void)
 
 void dlm_destroy_lock_cache(void)
 {
-       if (dlm_lock_cache)
-               kmem_cache_destroy(dlm_lock_cache);
+       kmem_cache_destroy(dlm_lock_cache);
 }
 
 /* Tell us whether we can grant a new lock request.
index a7df226f944946be1f70fa24fc2de76cb573a5f2..03766fb41dbe6ac544715b8cfe62bc7bb3e54a5e 100644 (file)
@@ -414,8 +414,7 @@ int dlm_init_mle_cache(void)
 
 void dlm_destroy_mle_cache(void)
 {
-       if (dlm_mle_cache)
-               kmem_cache_destroy(dlm_mle_cache);
+       kmem_cache_destroy(dlm_mle_cache);
 }
 
 static void dlm_mle_release(struct kref *kref)
@@ -472,15 +471,11 @@ int dlm_init_master_caches(void)
 
 void dlm_destroy_master_caches(void)
 {
-       if (dlm_lockname_cache) {
-               kmem_cache_destroy(dlm_lockname_cache);
-               dlm_lockname_cache = NULL;
-       }
+       kmem_cache_destroy(dlm_lockname_cache);
+       dlm_lockname_cache = NULL;
 
-       if (dlm_lockres_cache) {
-               kmem_cache_destroy(dlm_lockres_cache);
-               dlm_lockres_cache = NULL;
-       }
+       kmem_cache_destroy(dlm_lockres_cache);
+       dlm_lockres_cache = NULL;
 }
 
 static void dlm_lockres_release(struct kref *kref)
index e4d54d2805d6ba894637a138a40d0570b8f725f2..a49b7c2bde9e435e56aa54a53eac0732e9bcc4bb 100644 (file)
@@ -1768,12 +1768,9 @@ static int ocfs2_initialize_mem_caches(void)
                                        NULL);
        if (!ocfs2_inode_cachep || !ocfs2_dquot_cachep ||
            !ocfs2_qf_chunk_cachep) {
-               if (ocfs2_inode_cachep)
-                       kmem_cache_destroy(ocfs2_inode_cachep);
-               if (ocfs2_dquot_cachep)
-                       kmem_cache_destroy(ocfs2_dquot_cachep);
-               if (ocfs2_qf_chunk_cachep)
-                       kmem_cache_destroy(ocfs2_qf_chunk_cachep);
+               kmem_cache_destroy(ocfs2_inode_cachep);
+               kmem_cache_destroy(ocfs2_dquot_cachep);
+               kmem_cache_destroy(ocfs2_qf_chunk_cachep);
                return -ENOMEM;
        }
 
@@ -1787,16 +1784,13 @@ static void ocfs2_free_mem_caches(void)
         * destroy cache.
         */
        rcu_barrier();
-       if (ocfs2_inode_cachep)
-               kmem_cache_destroy(ocfs2_inode_cachep);
+       kmem_cache_destroy(ocfs2_inode_cachep);
        ocfs2_inode_cachep = NULL;
 
-       if (ocfs2_dquot_cachep)
-               kmem_cache_destroy(ocfs2_dquot_cachep);
+       kmem_cache_destroy(ocfs2_dquot_cachep);
        ocfs2_dquot_cachep = NULL;
 
-       if (ocfs2_qf_chunk_cachep)
-               kmem_cache_destroy(ocfs2_qf_chunk_cachep);
+       kmem_cache_destroy(ocfs2_qf_chunk_cachep);
        ocfs2_qf_chunk_cachep = NULL;
 }
 
index 82e17b076ce7829f98af5dbf56d53201dee4a601..78f09c76ab3c3f61a58a3926a620874f2e875f2a 100644 (file)
@@ -633,6 +633,5 @@ int __init init_ocfs2_uptodate_cache(void)
 
 void exit_ocfs2_uptodate_cache(void)
 {
-       if (ocfs2_uptodate_cachep)
-               kmem_cache_destroy(ocfs2_uptodate_cachep);
+       kmem_cache_destroy(ocfs2_uptodate_cachep);
 }