summaryrefslogtreecommitdiff
path: root/include/net/dst.h
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2017-06-17 10:42:44 -0700
committerDavid S. Miller <davem@davemloft.net>2017-06-17 22:54:01 -0400
commit44ebe79149ff415e810529bf192faa5c38d4a0de (patch)
tree84d1cd1b7a6b3990749e2423a6a2a38a2478acd7 /include/net/dst.h
parent1eb04e7c9e63e0480cc52b84187283de4fe5f982 (diff)
net: add debug atomic_inc_not_zero() in dst_hold()
This patch is meant to add a debug warning on the situation where dst is being held during its destroy phase. This could potentially cause double free issue on the dst. Signed-off-by: Wei Wang <weiwan@google.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/dst.h')
-rw-r--r--include/net/dst.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index d912b44d2dcb..f73611ec4017 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -251,7 +251,7 @@ static inline void dst_hold(struct dst_entry *dst)
* __pad_to_align_refcnt declaration in struct dst_entry
*/
BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63);
- atomic_inc(&dst->__refcnt);
+ WARN_ON(atomic_inc_not_zero(&dst->__refcnt) == 0);
}
static inline void dst_use(struct dst_entry *dst, unsigned long time)