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

net/ipv6: prefer rcu_access_pointer() over rcu_dereference()

rt6_cache_allowed_for_pmtu() checks for rt->from presence, but
it does not access the RCU protected pointer. We can use
rcu_access_pointer() and clean-up the code a bit. No functional
changes intended.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Paolo Abeni and committed by
David S. Miller
1490ed2a 59e6158a

+1 -7
+1 -7
net/ipv6/route.c
··· 2277 2277 2278 2278 static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt) 2279 2279 { 2280 - bool from_set; 2281 - 2282 - rcu_read_lock(); 2283 - from_set = !!rcu_dereference(rt->from); 2284 - rcu_read_unlock(); 2285 - 2286 2280 return !(rt->rt6i_flags & RTF_CACHE) && 2287 - (rt->rt6i_flags & RTF_PCPU || from_set); 2281 + (rt->rt6i_flags & RTF_PCPU || rcu_access_pointer(rt->from)); 2288 2282 } 2289 2283 2290 2284 static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,