aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/inetpeer.h2
-rw-r--r--net/ipv4/route.c11
-rw-r--r--net/ipv6/route.c10
3 files changed, 13 insertions, 10 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index e15c0862a686..c27c8f10ebdc 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -104,7 +104,7 @@ static inline bool inetpeer_ptr_set_peer(unsigned long *ptr, struct inet_peer *p
104 unsigned long val = (unsigned long) peer; 104 unsigned long val = (unsigned long) peer;
105 unsigned long orig = *ptr; 105 unsigned long orig = *ptr;
106 106
107 if (!(orig & INETPEER_BASE_BIT) || !val || 107 if (!(orig & INETPEER_BASE_BIT) ||
108 cmpxchg(ptr, orig, val) != orig) 108 cmpxchg(ptr, orig, val) != orig)
109 return false; 109 return false;
110 return true; 110 return true;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 4c33ce3000ed..842510d50453 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1333,11 +1333,12 @@ void rt_bind_peer(struct rtable *rt, __be32 daddr, int create)
1333 return; 1333 return;
1334 1334
1335 peer = inet_getpeer_v4(base, daddr, create); 1335 peer = inet_getpeer_v4(base, daddr, create);
1336 1336 if (peer) {
1337 if (!rt_set_peer(rt, peer)) 1337 if (!rt_set_peer(rt, peer))
1338 inet_putpeer(peer); 1338 inet_putpeer(peer);
1339 else 1339 else
1340 rt->rt_peer_genid = rt_peer_genid(); 1340 rt->rt_peer_genid = rt_peer_genid();
1341 }
1341} 1342}
1342 1343
1343/* 1344/*
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d9ba4808f26a..58a3ec23da2f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -313,10 +313,12 @@ void rt6_bind_peer(struct rt6_info *rt, int create)
313 return; 313 return;
314 314
315 peer = inet_getpeer_v6(base, &rt->rt6i_dst.addr, create); 315 peer = inet_getpeer_v6(base, &rt->rt6i_dst.addr, create);
316 if (!rt6_set_peer(rt, peer)) 316 if (peer) {
317 inet_putpeer(peer); 317 if (!rt6_set_peer(rt, peer))
318 else 318 inet_putpeer(peer);
319 rt->rt6i_peer_genid = rt6_peer_genid(); 319 else
320 rt->rt6i_peer_genid = rt6_peer_genid();
321 }
320} 322}
321 323
322static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, 324static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,