Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4c5fba2 authored by Ying Xue's avatar Ying Xue Committed by David S. Miller
Browse files

decnet: use __dev_get_by_index instead of dev_get_by_index to find interface



The following call chain we can identify that dn_cache_getroute() is
protected under rtnl_lock. So if we use __dev_get_by_index() instead
of dev_get_by_index() to find interface handlers in it, this would help
us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
    netlink_rcv_skb()
      dn_cache_getroute()
  rtnl_unlock()

Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9ac62be
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -1666,12 +1666,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)

	if (fld.flowidn_iif) {
		struct net_device *dev;
		if ((dev = dev_get_by_index(&init_net, fld.flowidn_iif)) == NULL) {
			kfree_skb(skb);
			return -ENODEV;
		}
		if (!dev->dn_ptr) {
			dev_put(dev);
		dev = __dev_get_by_index(&init_net, fld.flowidn_iif);
		if (!dev || !dev->dn_ptr) {
			kfree_skb(skb);
			return -ENODEV;
		}
@@ -1693,8 +1689,6 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
		err = dn_route_output_key((struct dst_entry **)&rt, &fld, 0);
	}

	if (skb->dev)
		dev_put(skb->dev);
	skb->dev = NULL;
	if (err)
		goto out_free;