xfrm: policy: xfrm_policy_unregister_afinfo can return void

Nothing checks the return value. Also, the errors returned on unregister
are impossible (we only support INET and INET6, so no way
xfrm_policy_afinfo[afinfo->family] can be anything other than 'afinfo'
itself).

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Florian Westphal 2017-02-07 15:00:15 +01:00 коммит произвёл Steffen Klassert
Родитель f5e2bb4f5b
Коммит 2b61997aa0
2 изменённых файлов: 14 добавлений и 23 удалений

Просмотреть файл

@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
}; };
int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); void xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
void km_policy_notify(struct xfrm_policy *xp, int dir, void km_policy_notify(struct xfrm_policy *xp, int dir,
const struct km_event *c); const struct km_event *c);
void km_state_notify(struct xfrm_state *x, const struct km_event *c); void km_state_notify(struct xfrm_state *x, const struct km_event *c);

Просмотреть файл

@ -2883,34 +2883,25 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
} }
EXPORT_SYMBOL(xfrm_policy_register_afinfo); EXPORT_SYMBOL(xfrm_policy_register_afinfo);
int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo) void xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
{ {
int err = 0; struct dst_ops *dst_ops = afinfo->dst_ops;
if (unlikely(afinfo == NULL))
return -EINVAL;
if (unlikely(afinfo->family >= NPROTO)) if (unlikely(afinfo->family >= NPROTO))
return -EAFNOSUPPORT; return;
spin_lock(&xfrm_policy_afinfo_lock);
if (likely(xfrm_policy_afinfo[afinfo->family] != NULL)) { if (likely(xfrm_policy_afinfo[afinfo->family] != afinfo)) {
if (unlikely(xfrm_policy_afinfo[afinfo->family] != afinfo)) RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family],
err = -EINVAL;
else
RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family],
NULL); NULL);
} }
spin_unlock(&xfrm_policy_afinfo_lock);
if (!err) {
struct dst_ops *dst_ops = afinfo->dst_ops;
synchronize_rcu(); synchronize_rcu();
dst_ops->kmem_cachep = NULL; dst_ops->kmem_cachep = NULL;
dst_ops->check = NULL; dst_ops->check = NULL;
dst_ops->negative_advice = NULL; dst_ops->negative_advice = NULL;
dst_ops->link_failure = NULL; dst_ops->link_failure = NULL;
afinfo->garbage_collect = NULL; afinfo->garbage_collect = NULL;
}
return err;
} }
EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); EXPORT_SYMBOL(xfrm_policy_unregister_afinfo);