if (type & IPV6_ADDR_LINKLOCAL) {
if (!addr->v6.sin6_scope_id)
return 0;
- dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
- if (!dev)
- return 0;
- if (!ipv6_chk_addr(&init_net, &addr->v6.sin6_addr,
+ rcu_read_lock();
+ dev = dev_get_by_index_rcu(&init_net,
+ addr->v6.sin6_scope_id);
+ if (!dev ||
+ !ipv6_chk_addr(&init_net, &addr->v6.sin6_addr,
dev, 0)) {
- dev_put(dev);
+ rcu_read_unlock();
return 0;
}
- dev_put(dev);
+ rcu_read_unlock();
} else if (type == IPV6_ADDR_MAPPED) {
if (!opt->v4mapped)
return 0;
if (type & IPV6_ADDR_LINKLOCAL) {
if (!addr->v6.sin6_scope_id)
return 0;
- dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
+ rcu_read_lock();
+ dev = dev_get_by_index_rcu(&init_net,
+ addr->v6.sin6_scope_id);
+ rcu_read_unlock();
if (!dev)
return 0;
- dev_put(dev);
}
af = opt->pf->af;
}