aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter/nf_nat_redirect.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-05-31 18:27:09 +0200
committerDavid S. Miller <davem@davemloft.net>2019-06-02 18:08:36 -0700
commit2638eb8b50cfc16240e0bb080b9afbf541a9b39d (patch)
tree84264a6f50aaedfac6854bef3d5972926d321c10 /net/netfilter/nf_nat_redirect.c
parentdrivers: use in_dev_for_each_ifa_rtnl/rcu (diff)
downloadlinux-dev-2638eb8b50cfc16240e0bb080b9afbf541a9b39d.tar.xz
linux-dev-2638eb8b50cfc16240e0bb080b9afbf541a9b39d.zip
net: ipv4: provide __rcu annotation for ifa_list
ifa_list is protected by rcu, yet code doesn't reflect this. Add the __rcu annotations and fix up all places that are now reported by sparse. I've done this in the same commit to not add intermediate patches that result in new warnings. Reported-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter/nf_nat_redirect.c')
-rw-r--r--net/netfilter/nf_nat_redirect.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c
index 78a9e6454ff3..8598e80968e0 100644
--- a/net/netfilter/nf_nat_redirect.c
+++ b/net/netfilter/nf_nat_redirect.c
@@ -47,15 +47,17 @@ nf_nat_redirect_ipv4(struct sk_buff *skb,
if (hooknum == NF_INET_LOCAL_OUT) {
newdst = htonl(0x7F000001);
} else {
- struct in_device *indev;
- struct in_ifaddr *ifa;
+ const struct in_device *indev;
newdst = 0;
indev = __in_dev_get_rcu(skb->dev);
- if (indev && indev->ifa_list) {
- ifa = indev->ifa_list;
- newdst = ifa->ifa_local;
+ if (indev) {
+ const struct in_ifaddr *ifa;
+
+ ifa = rcu_dereference(indev->ifa_list);
+ if (ifa)
+ newdst = ifa->ifa_local;
}
if (!newdst)