Skip to content

Commit

Permalink
net: print proper warning on dst underflow
Browse files Browse the repository at this point in the history
Proper warnings with stack traces make it much easier to figure out
what's doing the double free and create more meaningful bug reports from
users.

Signed-off-by: Jason A. Donenfeld <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
zx2c4 authored and davem330 committed Sep 26, 2019
1 parent 3e8b9bf commit adecda5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void dst_release(struct dst_entry *dst)
int newrefcnt;

newrefcnt = atomic_dec_return(&dst->__refcnt);
if (unlikely(newrefcnt < 0))
if (WARN_ONCE(newrefcnt < 0, "dst_release underflow"))
net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
__func__, dst, newrefcnt);
if (!newrefcnt)
Expand All @@ -187,7 +187,7 @@ void dst_release_immediate(struct dst_entry *dst)
int newrefcnt;

newrefcnt = atomic_dec_return(&dst->__refcnt);
if (unlikely(newrefcnt < 0))
if (WARN_ONCE(newrefcnt < 0, "dst_release_immediate underflow"))
net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
__func__, dst, newrefcnt);
if (!newrefcnt)
Expand Down

0 comments on commit adecda5

Please sign in to comment.