Skip to contentSkip to conversation

arch/x86: remove redundant null checks before kmem_cache_destroy

PATCH Applied Tim Hansen 2 participants 2 messages Oct 8, 2017 – Oct 10, 2017

Subsystems (3)
lore
Share & tools
lore

Tim Hansen

author
#0 lore raw

PATCH 1/1 arch/x86: remove redundant null checks before kmem_cache_destroy

Remove redundant null checks before calling kmem_cache_destroy.

Found with make coccicheck M=arch/x86/kvm on linux-next tag next-20170929.

---
 arch/x86/kvm/mmu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu.c +2 -4
index eca30c1eb1d9..a6c7177326c5 100644
@@ -5463,10 +5463,8 @@ static struct shrinker mmu_shrinker = {
 
 static void mmu_destroy_caches(void)
 {
-	if (pte_list_desc_cache)
-		kmem_cache_destroy(pte_list_desc_cache);
-	if (mmu_page_header_cache)
-		kmem_cache_destroy(mmu_page_header_cache);
+	kmem_cache_destroy(pte_list_desc_cache);
+	kmem_cache_destroy(mmu_page_header_cache);
 }
 
 int kvm_mmu_module_init(void)
Signature · 1 line
2.14.2
maintainer Applied
#1 lore raw
Quoted 18 lines · Tim Hansen

Remove redundant null checks before calling kmem_cache_destroy.

Found with make coccicheck M=arch/x86/kvm on linux-next tag next-20170929.

---
 arch/x86/kvm/mmu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu.c +0 -0
index eca30c1eb1d9..a6c7177326c5 100644
@@ -5463,10 +5463,8 @@ static struct shrinker mmu_shrinker = {
 
 static void mmu_destroy_caches(void)

arch/x86/kvm/mmu.c static struct shrinker mmu_shrinker = { · line 5470

Quoted 10 lines
arch/x86/kvm/mmu.c +2 -4
 {
-	if (pte_list_desc_cache)
-		kmem_cache_destroy(pte_list_desc_cache);
-	if (mmu_page_header_cache)
-		kmem_cache_destroy(mmu_page_header_cache);
+	kmem_cache_destroy(pte_list_desc_cache);
+	kmem_cache_destroy(mmu_page_header_cache);
 }
 
 int kvm_mmu_module_init(void)

Queued, thanks.

Paolo