Skip to content

Commit

Permalink
dcb: use __dev_get_by_name instead of dev_get_by_name to find interface
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ying Xue <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ying-xue authored and davem330 committed Jan 15, 2014
1 parent ebd93a7 commit d9ac62b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions net/dcb/dcbnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
if (!tb[DCB_ATTR_IFNAME])
return -EINVAL;

netdev = dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
netdev = __dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
if (!netdev)
return -ENODEV;

if (!netdev->dcbnl_ops) {
ret = -EOPNOTSUPP;
goto out;
}
if (!netdev->dcbnl_ops)
return -EOPNOTSUPP;

reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq,
nlh->nlmsg_flags, &reply_nlh);
if (!reply_skb) {
ret = -ENOBUFS;
goto out;
}
if (!reply_skb)
return -ENOBUFS;

ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb);
if (ret < 0) {
Expand All @@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)

ret = rtnl_unicast(reply_skb, net, portid);
out:
dev_put(netdev);
return ret;
}

Expand Down

0 comments on commit d9ac62b

Please sign in to comment.