OSDN Git Service

net: print proper warning on dst underflow
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 24 Sep 2019 09:09:37 +0000 (11:09 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Sep 2019 07:05:56 +0000 (09:05 +0200)
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 <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dst.c

index 1325316..193af52 100644 (file)
@@ -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)
@@ -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)