From f0e648bfa30958f47f1e7bbe656ebe0f4556a52a Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 22 Dec 2011 15:48:49 -0500 Subject: [PATCH] afs: Panic on afs_conn refcount imbalance An undercounted afs_conn can easily cause a panic and/or memory corruption later on, since we put an rx_connection reference with each afs_conn reference. Panic as soon as we detect this, as this indicates a serious bug. Reviewed-on: http://gerrit.openafs.org/6413 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 8a574ba16a80fc2b8b703ddcfc99486b977e6071) Change-Id: Ibd60dafdf1a800349b73754dae18666fa0edd300 Reviewed-on: http://gerrit.openafs.org/6642 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/afs_conn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index cbe1fcbaf..95baf6c4a 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -479,6 +479,10 @@ afs_PutConn(struct afs_conn *ac, struct rx_connection *rxconn, { AFS_STATCNT(afs_PutConn); ac->refCount--; + if (ac->refCount < 0) { + osi_Panic("afs_PutConn: refcount imbalance 0x%lx %d", + (unsigned long)(uintptrsz)ac, (int)ac->refCount); + } rx_PutConnection(rxconn); } /*afs_PutConn */ -- 2.39.5