[patch v1 05/12] IPVS: Allow null argument to ip_vs_scheduler_put()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Simon Horman
Date: Sunday, August 22, 2010 - 5:45 am

This simplifies caller logic sightly.

Signed-off-by: Simon Horman <horms@verge.net.au>

Index: nf-next-2.6/net/netfilter/ipvs/ip_vs_ctl.c
===================================================================
--- nf-next-2.6.orig/net/netfilter/ipvs/ip_vs_ctl.c	2010-07-22 21:52:23.000000000 +0900
+++ nf-next-2.6/net/netfilter/ipvs/ip_vs_ctl.c	2010-07-22 21:54:38.000000000 +0900
@@ -1167,7 +1167,7 @@ ip_vs_add_service(struct ip_vs_service_u
 	if (sched == NULL) {
 		pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name);
 		ret = -ENOENT;
-		goto out_mod_dec;
+		goto out_err;
 	}
 
 #ifdef CONFIG_IP_VS_IPV6
@@ -1227,7 +1227,7 @@ ip_vs_add_service(struct ip_vs_service_u
 	*svc_p = svc;
 	return 0;
 
-  out_err:
+ out_err:
 	if (svc != NULL) {
 		if (svc->scheduler)
 			ip_vs_unbind_scheduler(svc);
@@ -1240,7 +1240,6 @@ ip_vs_add_service(struct ip_vs_service_u
 	}
 	ip_vs_scheduler_put(sched);
 
-  out_mod_dec:
 	/* decrease the module use count */
 	ip_vs_use_count_dec();
 
@@ -1323,10 +1322,7 @@ ip_vs_edit_service(struct ip_vs_service
 #ifdef CONFIG_IP_VS_IPV6
   out:
 #endif
-
-	if (old_sched)
-		ip_vs_scheduler_put(old_sched);
-
+	ip_vs_scheduler_put(old_sched);
 	return ret;
 }
 
@@ -1350,8 +1346,7 @@ static void __ip_vs_del_service(struct i
 	/* Unbind scheduler */
 	old_sched = svc->scheduler;
 	ip_vs_unbind_scheduler(svc);
-	if (old_sched)
-		ip_vs_scheduler_put(old_sched);
+	ip_vs_scheduler_put(old_sched);
 
 	/* Unbind app inc */
 	if (svc->inc) {
Index: nf-next-2.6/net/netfilter/ipvs/ip_vs_sched.c
===================================================================
--- nf-next-2.6.orig/net/netfilter/ipvs/ip_vs_sched.c	2010-07-22 21:52:23.000000000 +0900
+++ nf-next-2.6/net/netfilter/ipvs/ip_vs_sched.c	2010-07-22 21:55:42.000000000 +0900
@@ -159,7 +159,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_
 
 void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
 {
-	if (scheduler->module)
+	if (scheduler && scheduler->module)
 		module_put(scheduler->module);
 }
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch v1 00/12] IPVS: SIP Persistence Engine, Simon Horman, (Sun Aug 22, 5:44 am)
[patch v1 04/12] IPVS: Add struct ip_vs_conn_param, Simon Horman, (Sun Aug 22, 5:45 am)
[patch v1 05/12] IPVS: Allow null argument to ip_vs_schedu ..., Simon Horman, (Sun Aug 22, 5:45 am)
Re: [patch v1 00/12] IPVS: SIP Persistence Engine, Simon Horman, (Sun Aug 22, 5:57 am)
Re: [patch v1 00/12] IPVS: SIP Persistence Engine, Patrick McHardy, (Thu Sep 16, 1:12 am)
Re: [patch v1 00/12] IPVS: SIP Persistence Engine, Simon Horman, (Thu Sep 16, 7:52 pm)
Re: [patch v1 00/12] IPVS: SIP Persistence Engine, Patrick McHardy, (Fri Sep 17, 4:53 am)
Re: [patch v1 00/12] IPVS: SIP Persistence Engine, Simon Horman, (Sat Sep 18, 5:52 am)