xfrm: policy: xfrm_policy_unregister_afinfo can return void
authorFlorian Westphal <fw@strlen.de>
Tue, 7 Feb 2017 14:00:15 +0000 (15:00 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 9 Feb 2017 09:22:17 +0000 (10:22 +0100)
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>
include/net/xfrm.h
net/xfrm/xfrm_policy.c

index da0e4dd653e28eaaf1446cddf545e45a92bf3af2..39037b1cce7a41fe943b27bddae56fa91bc47677 100644 (file)
@@ -304,7 +304,7 @@ struct xfrm_policy_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,
                      const struct km_event *c);
 void km_state_notify(struct xfrm_state *x, const struct km_event *c);
index 6fffa2fac60772c705830669c706179030b64f50..794148f76ae2e4bb4a2ab12b366e0ae45ca5a628 100644 (file)
@@ -2883,34 +2883,25 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *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;
-       if (unlikely(afinfo == NULL))
-               return -EINVAL;
+       struct dst_ops *dst_ops = afinfo->dst_ops;
+
        if (unlikely(afinfo->family >= NPROTO))
-               return -EAFNOSUPPORT;
-       spin_lock(&xfrm_policy_afinfo_lock);
-       if (likely(xfrm_policy_afinfo[afinfo->family] != NULL)) {
-               if (unlikely(xfrm_policy_afinfo[afinfo->family] != afinfo))
-                       err = -EINVAL;
-               else
-                       RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family],
+               return;
+
+       if (likely(xfrm_policy_afinfo[afinfo->family] != afinfo)) {
+               RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family],
                                         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->check = NULL;
-               dst_ops->negative_advice = NULL;
-               dst_ops->link_failure = NULL;
-               afinfo->garbage_collect = NULL;
-       }
-       return err;
+       dst_ops->kmem_cachep = NULL;
+       dst_ops->check = NULL;
+       dst_ops->negative_advice = NULL;
+       dst_ops->link_failure = NULL;
+       afinfo->garbage_collect = NULL;
 }
 EXPORT_SYMBOL(xfrm_policy_unregister_afinfo);