ipv6: fix unappropriate errno returned for non-multicast address
authorLi Wei <lw@cn.fujitsu.com>
Tue, 17 Jul 2012 07:28:59 +0000 (15:28 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 17 Jul 2012 08:35:03 +0000 (01:35 -0700)
We need to check the passed in multicast address and return
appropriate errno(EINVAL) if it is not valid. And it's no need
to walk through the ipv6_mc_list in this situation.

Signed-off-by: Li Wei <lw@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/mcast.c

index 6d0f5dc8e3a608747bb4347546368fc1342c0f69..92f8e48e4ba4e63606412e317c28d2153eddccb0 100644 (file)
@@ -211,6 +211,9 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
        struct ipv6_mc_socklist __rcu **lnk;
        struct net *net = sock_net(sk);
 
+       if (!ipv6_addr_is_multicast(addr))
+               return -EINVAL;
+
        spin_lock(&ipv6_sk_mc_lock);
        for (lnk = &np->ipv6_mc_list;
             (mc_lst = rcu_dereference_protected(*lnk,