From: Wei Wang Subject: [PATCH v2 net-next 21/21] net: add debug atomic_inc_not_zero() in dst_hold() Date: Sat, 17 Jun 2017 10:42:44 -0700 Message-ID: <20170617174244.132862-22-tracywwnj@gmail.com> References: <20170617174244.132862-1-tracywwnj@gmail.com> Cc: Eric Dumazet , Martin KaFai Lau , Wei Wang To: David Miller , netdev@vger.kernel.org Return-path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:35021 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752792AbdFQRnv (ORCPT ); Sat, 17 Jun 2017 13:43:51 -0400 Received: by mail-pf0-f193.google.com with SMTP id s66so11093738pfs.2 for ; Sat, 17 Jun 2017 10:43:51 -0700 (PDT) In-Reply-To: <20170617174244.132862-1-tracywwnj@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Wei Wang 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 Acked-by: Martin KaFai Lau --- include/net/dst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- 2.13.1.518.g3df882009-goog