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>
This commit is contained in:
@@ -1144,7 +1144,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
|
|||||||
if (sched == NULL) {
|
if (sched == NULL) {
|
||||||
pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name);
|
pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name);
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto out_mod_dec;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_IP_VS_IPV6
|
#ifdef CONFIG_IP_VS_IPV6
|
||||||
@@ -1204,7 +1204,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
|
|||||||
*svc_p = svc;
|
*svc_p = svc;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
if (svc != NULL) {
|
if (svc != NULL) {
|
||||||
if (svc->scheduler)
|
if (svc->scheduler)
|
||||||
ip_vs_unbind_scheduler(svc);
|
ip_vs_unbind_scheduler(svc);
|
||||||
@@ -1217,7 +1217,6 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
|
|||||||
}
|
}
|
||||||
ip_vs_scheduler_put(sched);
|
ip_vs_scheduler_put(sched);
|
||||||
|
|
||||||
out_mod_dec:
|
|
||||||
/* decrease the module use count */
|
/* decrease the module use count */
|
||||||
ip_vs_use_count_dec();
|
ip_vs_use_count_dec();
|
||||||
|
|
||||||
@@ -1300,10 +1299,7 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
|
|||||||
#ifdef CONFIG_IP_VS_IPV6
|
#ifdef CONFIG_IP_VS_IPV6
|
||||||
out:
|
out:
|
||||||
#endif
|
#endif
|
||||||
|
ip_vs_scheduler_put(old_sched);
|
||||||
if (old_sched)
|
|
||||||
ip_vs_scheduler_put(old_sched);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,8 +1323,7 @@ static void __ip_vs_del_service(struct ip_vs_service *svc)
|
|||||||
/* Unbind scheduler */
|
/* Unbind scheduler */
|
||||||
old_sched = svc->scheduler;
|
old_sched = svc->scheduler;
|
||||||
ip_vs_unbind_scheduler(svc);
|
ip_vs_unbind_scheduler(svc);
|
||||||
if (old_sched)
|
ip_vs_scheduler_put(old_sched);
|
||||||
ip_vs_scheduler_put(old_sched);
|
|
||||||
|
|
||||||
/* Unbind app inc */
|
/* Unbind app inc */
|
||||||
if (svc->inc) {
|
if (svc->inc) {
|
||||||
|
@@ -159,7 +159,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name)
|
|||||||
|
|
||||||
void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
|
void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
|
||||||
{
|
{
|
||||||
if (scheduler->module)
|
if (scheduler && scheduler->module)
|
||||||
module_put(scheduler->module);
|
module_put(scheduler->module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user