Skip to contentSkip to conversation

ipv6: fix unappropriate errno returned for non-multicast address

PATCH Applied Li Wei 2 participants 2 messages Jul 17, 2012

Subsystems (3)
lore
Share & tools
lore

Li Wei

author
#0 lore raw

PATCH 1/1 ipv6: fix unappropriate errno returned for non-multicast address

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.

---
 net/ipv6/mcast.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
net/ipv6/mcast.c +3 -0
index 6d0f5dc..92f8e48 100644
@@ -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,
Signature · 1 line
1.7.1
maintainer Applied
#1 lore raw

From: Li Wei <[email protected]>
Date: Tue, 17 Jul 2012 15:28:59 +0800

Quoted 5 lines

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.

Applied to net-next, thanks.