aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2014-12-16 15:05:20 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-16 15:20:41 -0500
commitbb1553c800227f33063fe96561af881619447b83 (patch)
treed58e5c18d590519e56a039fc9dea063ed29b0646 /net
parentc9f2c3d36c10717159caae4b66410f74ce45d30c (diff)
ip_tunnel: Add sanity checks to ip_tunnel_encap_add_ops()
The symbols are exported and could be used by external modules. Fixes: a8c5f9 ("ip_tunnel: Ops registration for secondary encap (fou, gue)") Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_tunnel.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 63e745aadab6..2f498f87e3d8 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -514,6 +514,9 @@ const struct ip_tunnel_encap_ops __rcu *
514int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops, 514int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops,
515 unsigned int num) 515 unsigned int num)
516{ 516{
517 if (num >= MAX_IPTUN_ENCAP_OPS)
518 return -ERANGE;
519
517 return !cmpxchg((const struct ip_tunnel_encap_ops **) 520 return !cmpxchg((const struct ip_tunnel_encap_ops **)
518 &iptun_encaps[num], 521 &iptun_encaps[num],
519 NULL, ops) ? 0 : -1; 522 NULL, ops) ? 0 : -1;
@@ -525,6 +528,9 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *ops,
525{ 528{
526 int ret; 529 int ret;
527 530
531 if (num >= MAX_IPTUN_ENCAP_OPS)
532 return -ERANGE;
533
528 ret = (cmpxchg((const struct ip_tunnel_encap_ops **) 534 ret = (cmpxchg((const struct ip_tunnel_encap_ops **)
529 &iptun_encaps[num], 535 &iptun_encaps[num],
530 ops, NULL) == ops) ? 0 : -1; 536 ops, NULL) == ops) ? 0 : -1;