提交 5af28de3 编写于 作者: Y Ying Xue 提交者: David S. Miller

can: use __dev_get_by_index instead of dev_get_by_index to find interface

As cgw_create_job() is always under rtnl_lock protection,
__dev_get_by_index() instead of dev_get_by_index() should be used to
find interface handler in it having us avoid to change interface
reference counter.

Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: NYing Xue <ying.xue@windriver.com>
Acked-by: NOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a74e9426
...@@ -839,21 +839,21 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -839,21 +839,21 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx) if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx)
goto out; goto out;
gwj->src.dev = dev_get_by_index(&init_net, gwj->ccgw.src_idx); gwj->src.dev = __dev_get_by_index(&init_net, gwj->ccgw.src_idx);
if (!gwj->src.dev) if (!gwj->src.dev)
goto out; goto out;
if (gwj->src.dev->type != ARPHRD_CAN) if (gwj->src.dev->type != ARPHRD_CAN)
goto put_src_out; goto out;
gwj->dst.dev = dev_get_by_index(&init_net, gwj->ccgw.dst_idx); gwj->dst.dev = __dev_get_by_index(&init_net, gwj->ccgw.dst_idx);
if (!gwj->dst.dev) if (!gwj->dst.dev)
goto put_src_out; goto out;
if (gwj->dst.dev->type != ARPHRD_CAN) if (gwj->dst.dev->type != ARPHRD_CAN)
goto put_src_dst_out; goto out;
gwj->limit_hops = limhops; gwj->limit_hops = limhops;
...@@ -862,11 +862,6 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -862,11 +862,6 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
err = cgw_register_filter(gwj); err = cgw_register_filter(gwj);
if (!err) if (!err)
hlist_add_head_rcu(&gwj->list, &cgw_list); hlist_add_head_rcu(&gwj->list, &cgw_list);
put_src_dst_out:
dev_put(gwj->dst.dev);
put_src_out:
dev_put(gwj->src.dev);
out: out:
if (err) if (err)
kmem_cache_free(cgw_cache, gwj); kmem_cache_free(cgw_cache, gwj);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册