aboutsummaryrefslogtreecommitdiffstats
path: root/net/can
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-01-14 21:23:44 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-14 21:50:47 -0500
commit5af28de35342f630a91061e25cc976a01b7ca6c4 (patch)
tree6601cac6792af4d03ff3913f16fc73ecdbaa8c29 /net/can
parenta74e9426948cce451af0433c69a120178948cb03 (diff)
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: Ying Xue <ying.xue@windriver.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/can')
-rw-r--r--net/can/gw.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/net/can/gw.c b/net/can/gw.c
index 88c8a39c173d..ac31891967da 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -839,21 +839,21 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
839 if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx) 839 if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx)
840 goto out; 840 goto out;
841 841
842 gwj->src.dev = dev_get_by_index(&init_net, gwj->ccgw.src_idx); 842 gwj->src.dev = __dev_get_by_index(&init_net, gwj->ccgw.src_idx);
843 843
844 if (!gwj->src.dev) 844 if (!gwj->src.dev)
845 goto out; 845 goto out;
846 846
847 if (gwj->src.dev->type != ARPHRD_CAN) 847 if (gwj->src.dev->type != ARPHRD_CAN)
848 goto put_src_out; 848 goto out;
849 849
850 gwj->dst.dev = dev_get_by_index(&init_net, gwj->ccgw.dst_idx); 850 gwj->dst.dev = __dev_get_by_index(&init_net, gwj->ccgw.dst_idx);
851 851
852 if (!gwj->dst.dev) 852 if (!gwj->dst.dev)
853 goto put_src_out; 853 goto out;
854 854
855 if (gwj->dst.dev->type != ARPHRD_CAN) 855 if (gwj->dst.dev->type != ARPHRD_CAN)
856 goto put_src_dst_out; 856 goto out;
857 857
858 gwj->limit_hops = limhops; 858 gwj->limit_hops = limhops;
859 859
@@ -862,11 +862,6 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
862 err = cgw_register_filter(gwj); 862 err = cgw_register_filter(gwj);
863 if (!err) 863 if (!err)
864 hlist_add_head_rcu(&gwj->list, &cgw_list); 864 hlist_add_head_rcu(&gwj->list, &cgw_list);
865
866put_src_dst_out:
867 dev_put(gwj->dst.dev);
868put_src_out:
869 dev_put(gwj->src.dev);
870out: 865out:
871 if (err) 866 if (err)
872 kmem_cache_free(cgw_cache, gwj); 867 kmem_cache_free(cgw_cache, gwj);