netfilter: Deletion of unnecessary checks before two function calls
authorMarkus Elfring <elfring@users.sourceforge.net>
Tue, 18 Nov 2014 19:37:05 +0000 (20:37 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 20 Nov 2014 12:08:43 +0000 (13:08 +0100)
The functions free_percpu() and module_put() test whether their argument
is NULL and then return immediately. Thus the test around the call is
not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_pe.c
net/netfilter/ipvs/ip_vs_sched.c
net/netfilter/ipvs/ip_vs_sync.c
net/netfilter/nf_tables_api.c

index ac7ba689efe76c3e3df89c44dbd0094b08b6cf89..b8295a430a5600d35b6de4163ba3b98e75c5f28c 100644 (file)
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-       if (svc->stats.cpustats)
-               free_percpu(svc->stats.cpustats);
+       free_percpu(svc->stats.cpustats);
        kfree(svc);
 }
 
index 1a82b29ce8eab833cc83f05ba032431442b1c70d..0df17caa8af6cb82d022bc902602b64843a3fa54 100644 (file)
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
                        rcu_read_unlock();
                        return pe;
                }
-               if (pe->module)
-                       module_put(pe->module);
+               module_put(pe->module);
        }
        rcu_read_unlock();
 
index 4dbcda6258bc2c2c20ecc71e130d25a462a90be4..199760c71f3995f88dbe73b159906cf7840cdded 100644 (file)
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
                        mutex_unlock(&ip_vs_sched_mutex);
                        return sched;
                }
-               if (sched->module)
-                       module_put(sched->module);
+               module_put(sched->module);
        }
 
        mutex_unlock(&ip_vs_sched_mutex);
index 7162c86fd50dca443c0e7c3aa008cdb93038b7e3..c47ffd7a0a709cb73834c84652f251960f25db79 100644 (file)
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
                p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
                if (!p->pe_data) {
-                       if (p->pe->module)
-                               module_put(p->pe->module);
+                       module_put(p->pe->module);
                        return -ENOMEM;
                }
                p->pe_data_len = pe_data_len;
index 1ffb253c6a77139c6b69932fa586ef2f2abf765d..18a9daef22ddeaa2f5192c5235f1094157f1df18 100644 (file)
@@ -3674,8 +3674,7 @@ static int nf_tables_abort(struct sk_buff *skb)
                        break;
                case NFT_MSG_NEWCHAIN:
                        if (nft_trans_chain_update(trans)) {
-                               if (nft_trans_chain_stats(trans))
-                                       free_percpu(nft_trans_chain_stats(trans));
+                               free_percpu(nft_trans_chain_stats(trans));
 
                                nft_trans_destroy(trans);
                        } else {