Skip to content

Commit

Permalink
ipv6: fix unappropriate errno returned for non-multicast address
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Li Wei authored and David S. Miller committed Jul 17, 2012
1 parent c41e413 commit a858d64
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/ipv6/mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a858d64

Please sign in to comment.