IPVS: ip_vs_{un,}bind_scheduler NULL arguments
authorSimon Horman <horms@verge.net.au>
Sun, 22 Aug 2010 12:37:52 +0000 (21:37 +0900)
committerSimon Horman <horms@verge.net.au>
Mon, 4 Oct 2010 13:45:24 +0000 (22:45 +0900)
In general NULL arguments aren't passed by the few callers that exist,
so don't test for them.

The exception is to make passing NULL to ip_vs_unbind_scheduler() a noop.

Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Julian Anastasov <ja@ssi.bg>
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_sched.c

index f7afcfe4dbc5686f37108df1495f33a75f2433b6..5f20caf47a1d6cca18d2892e7e48618040c6abac 100644 (file)
@@ -1206,8 +1206,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
 
  out_err:
        if (svc != NULL) {
-               if (svc->scheduler)
-                       ip_vs_unbind_scheduler(svc);
+               ip_vs_unbind_scheduler(svc);
                if (svc->inc) {
                        local_bh_disable();
                        ip_vs_app_inc_put(svc->inc);
index 9f94e328d31e97c1984b622ce462826b813005dc..076ebe00435deef930f428fbb02414c550c14b98 100644 (file)
@@ -46,15 +46,6 @@ int ip_vs_bind_scheduler(struct ip_vs_service *svc,
 {
        int ret;
 
-       if (svc == NULL) {
-               pr_err("%s(): svc arg NULL\n", __func__);
-               return -EINVAL;
-       }
-       if (scheduler == NULL) {
-               pr_err("%s(): scheduler arg NULL\n", __func__);
-               return -EINVAL;
-       }
-
        svc->scheduler = scheduler;
 
        if (scheduler->init_service) {
@@ -74,18 +65,10 @@ int ip_vs_bind_scheduler(struct ip_vs_service *svc,
  */
 int ip_vs_unbind_scheduler(struct ip_vs_service *svc)
 {
-       struct ip_vs_scheduler *sched;
+       struct ip_vs_scheduler *sched = svc->scheduler;
 
-       if (svc == NULL) {
-               pr_err("%s(): svc arg NULL\n", __func__);
-               return -EINVAL;
-       }
-
-       sched = svc->scheduler;
-       if (sched == NULL) {
-               pr_err("%s(): svc isn't bound\n", __func__);
-               return -EINVAL;
-       }
+       if (!sched)
+               return 0;
 
        if (sched->done_service) {
                if (sched->done_service(svc) != 0) {