Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: core: drop null test before destroy functions

Remove unneeded NULL test.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ expression x; @@
-if (x != NULL) {
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
x = NULL;
-}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Julia Lawall and committed by
David S. Miller
adf78eda 58d29e3c

+4 -8
+4 -8
net/core/sock.c
··· 2740 2740 return; 2741 2741 kfree(rsk_prot->slab_name); 2742 2742 rsk_prot->slab_name = NULL; 2743 - if (rsk_prot->slab) { 2744 - kmem_cache_destroy(rsk_prot->slab); 2745 - rsk_prot->slab = NULL; 2746 - } 2743 + kmem_cache_destroy(rsk_prot->slab); 2744 + rsk_prot->slab = NULL; 2747 2745 } 2748 2746 2749 2747 static int req_prot_init(const struct proto *prot) ··· 2826 2828 list_del(&prot->node); 2827 2829 mutex_unlock(&proto_list_mutex); 2828 2830 2829 - if (prot->slab != NULL) { 2830 - kmem_cache_destroy(prot->slab); 2831 - prot->slab = NULL; 2832 - } 2831 + kmem_cache_destroy(prot->slab); 2832 + prot->slab = NULL; 2833 2833 2834 2834 req_prot_cleanup(prot->rsk_prot); 2835 2835