diff options
author | Ying Xue <ying.xue@windriver.com> | 2014-01-14 21:23:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-14 21:50:46 -0500 |
commit | d9ac62be5740272f495154469cc9f77feb8d541a (patch) | |
tree | 9ff0ca3ae3c0f647d402baf1cd6d1a3b1b63ba4f /net/dcb | |
parent | ebd93a7daf40d61b994b9928dd7bf26e0dcca10d (diff) |
dcb: use __dev_get_by_name instead of dev_get_by_name to find interface
The following call chain indicates that dcb_doit() is protected
under rtnl_lock. So if we use __dev_get_by_name() instead of
dev_get_by_name() to find interface handlers in it, this would
help us avoid to change interface reference counter.
rtnetlink_rcv()
rtnl_lock()
netlink_rcv_skb()
dcb_doit()
rtnl_unlock()
Cc: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dcb')
-rw-r--r-- | net/dcb/dcbnl.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 66fbe1948fb5..553644402670 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
@@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1688 | if (!tb[DCB_ATTR_IFNAME]) | 1688 | if (!tb[DCB_ATTR_IFNAME]) |
1689 | return -EINVAL; | 1689 | return -EINVAL; |
1690 | 1690 | ||
1691 | netdev = dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME])); | 1691 | netdev = __dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME])); |
1692 | if (!netdev) | 1692 | if (!netdev) |
1693 | return -ENODEV; | 1693 | return -ENODEV; |
1694 | 1694 | ||
1695 | if (!netdev->dcbnl_ops) { | 1695 | if (!netdev->dcbnl_ops) |
1696 | ret = -EOPNOTSUPP; | 1696 | return -EOPNOTSUPP; |
1697 | goto out; | ||
1698 | } | ||
1699 | 1697 | ||
1700 | reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq, | 1698 | reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq, |
1701 | nlh->nlmsg_flags, &reply_nlh); | 1699 | nlh->nlmsg_flags, &reply_nlh); |
1702 | if (!reply_skb) { | 1700 | if (!reply_skb) |
1703 | ret = -ENOBUFS; | 1701 | return -ENOBUFS; |
1704 | goto out; | ||
1705 | } | ||
1706 | 1702 | ||
1707 | ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb); | 1703 | ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb); |
1708 | if (ret < 0) { | 1704 | if (ret < 0) { |
@@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1714 | 1710 | ||
1715 | ret = rtnl_unicast(reply_skb, net, portid); | 1711 | ret = rtnl_unicast(reply_skb, net, portid); |
1716 | out: | 1712 | out: |
1717 | dev_put(netdev); | ||
1718 | return ret; | 1713 | return ret; |
1719 | } | 1714 | } |
1720 | 1715 | ||