Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ying Xue and committed by
David S. Miller
5af28de3 a74e9426

+5 -10
+5 -10
net/can/gw.c
··· 839 839 if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx) 840 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 844 if (!gwj->src.dev) 845 845 goto out; 846 846 847 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 852 if (!gwj->dst.dev) 853 - goto put_src_out; 853 + goto out; 854 854 855 855 if (gwj->dst.dev->type != ARPHRD_CAN) 856 - goto put_src_dst_out; 856 + goto out; 857 857 858 858 gwj->limit_hops = limhops; 859 859 ··· 862 862 err = cgw_register_filter(gwj); 863 863 if (!err) 864 864 hlist_add_head_rcu(&gwj->list, &cgw_list); 865 - 866 - put_src_dst_out: 867 - dev_put(gwj->dst.dev); 868 - put_src_out: 869 - dev_put(gwj->src.dev); 870 865 out: 871 866 if (err) 872 867 kmem_cache_free(cgw_cache, gwj);