dlm: NULL check before kmem_cache_destroy is not needed
authorWen Yang <wen.yang99@zte.com.cn>
Wed, 28 Nov 2018 07:25:00 +0000 (15:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Dec 2019 09:41:12 +0000 (10:41 +0100)
[ Upstream commit f31a89692830061bceba8469607e4e4b0f900159 ]

kmem_cache_destroy(NULL) is safe, so removes NULL check before
freeing the mem. This patch also fix ifnullfree.cocci warnings.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/dlm/memory.c

index 7cd24bccd4fe56aab54db611c4587a8bdc51a7e8..37be29f21d04df27c08840b6c7b45346834c006d 100644 (file)
@@ -38,10 +38,8 @@ int __init dlm_memory_init(void)
 
 void dlm_memory_exit(void)
 {
-       if (lkb_cache)
-               kmem_cache_destroy(lkb_cache);
-       if (rsb_cache)
-               kmem_cache_destroy(rsb_cache);
+       kmem_cache_destroy(lkb_cache);
+       kmem_cache_destroy(rsb_cache);
 }
 
 char *dlm_allocate_lvb(struct dlm_ls *ls)
@@ -86,8 +84,7 @@ void dlm_free_lkb(struct dlm_lkb *lkb)
                struct dlm_user_args *ua;
                ua = lkb->lkb_ua;
                if (ua) {
-                       if (ua->lksb.sb_lvbptr)
-                               kfree(ua->lksb.sb_lvbptr);
+                       kfree(ua->lksb.sb_lvbptr);
                        kfree(ua);
                }
        }