diff options
author | Simon Horman <horms@verge.net.au> | 2010-08-22 08:37:52 -0400 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2010-10-04 09:45:24 -0400 |
commit | 6e08bfb879574524cc9a67be960c684989fd986c (patch) | |
tree | 7ae752735101d2928993ad57f092904bfb81922f /net/netfilter | |
parent | f11017ec2d1859c661f4e2b12c4a8d250e1f47cf (diff) |
IPVS: Allow null argument to ip_vs_scheduler_put()
This simplifies caller logic sightly.
Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Julian Anastasov <ja@ssi.bg>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_ctl.c | 13 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_sched.c | 2 |
2 files changed, 5 insertions, 10 deletions
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index e4ec8f364f8b..f7afcfe4dbc5 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c | |||
@@ -1144,7 +1144,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u, | |||
1144 | if (sched == NULL) { | 1144 | if (sched == NULL) { |
1145 | pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name); | 1145 | pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name); |
1146 | ret = -ENOENT; | 1146 | ret = -ENOENT; |
1147 | goto out_mod_dec; | 1147 | goto out_err; |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | #ifdef CONFIG_IP_VS_IPV6 | 1150 | #ifdef CONFIG_IP_VS_IPV6 |
@@ -1204,7 +1204,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u, | |||
1204 | *svc_p = svc; | 1204 | *svc_p = svc; |
1205 | return 0; | 1205 | return 0; |
1206 | 1206 | ||
1207 | out_err: | 1207 | out_err: |
1208 | if (svc != NULL) { | 1208 | if (svc != NULL) { |
1209 | if (svc->scheduler) | 1209 | if (svc->scheduler) |
1210 | ip_vs_unbind_scheduler(svc); | 1210 | ip_vs_unbind_scheduler(svc); |
@@ -1217,7 +1217,6 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u, | |||
1217 | } | 1217 | } |
1218 | ip_vs_scheduler_put(sched); | 1218 | ip_vs_scheduler_put(sched); |
1219 | 1219 | ||
1220 | out_mod_dec: | ||
1221 | /* decrease the module use count */ | 1220 | /* decrease the module use count */ |
1222 | ip_vs_use_count_dec(); | 1221 | ip_vs_use_count_dec(); |
1223 | 1222 | ||
@@ -1300,10 +1299,7 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u) | |||
1300 | #ifdef CONFIG_IP_VS_IPV6 | 1299 | #ifdef CONFIG_IP_VS_IPV6 |
1301 | out: | 1300 | out: |
1302 | #endif | 1301 | #endif |
1303 | 1302 | ip_vs_scheduler_put(old_sched); | |
1304 | if (old_sched) | ||
1305 | ip_vs_scheduler_put(old_sched); | ||
1306 | |||
1307 | return ret; | 1303 | return ret; |
1308 | } | 1304 | } |
1309 | 1305 | ||
@@ -1327,8 +1323,7 @@ static void __ip_vs_del_service(struct ip_vs_service *svc) | |||
1327 | /* Unbind scheduler */ | 1323 | /* Unbind scheduler */ |
1328 | old_sched = svc->scheduler; | 1324 | old_sched = svc->scheduler; |
1329 | ip_vs_unbind_scheduler(svc); | 1325 | ip_vs_unbind_scheduler(svc); |
1330 | if (old_sched) | 1326 | ip_vs_scheduler_put(old_sched); |
1331 | ip_vs_scheduler_put(old_sched); | ||
1332 | 1327 | ||
1333 | /* Unbind app inc */ | 1328 | /* Unbind app inc */ |
1334 | if (svc->inc) { | 1329 | if (svc->inc) { |
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c index 727e45b66953..9f94e328d31e 100644 --- a/net/netfilter/ipvs/ip_vs_sched.c +++ b/net/netfilter/ipvs/ip_vs_sched.c | |||
@@ -159,7 +159,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name) | |||
159 | 159 | ||
160 | void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler) | 160 | void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler) |
161 | { | 161 | { |
162 | if (scheduler->module) | 162 | if (scheduler && scheduler->module) |
163 | module_put(scheduler->module); | 163 | module_put(scheduler->module); |
164 | } | 164 | } |
165 | 165 | ||