From 8a574ba16a80fc2b8b703ddcfc99486b977e6071 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. Change-Id: I251fd3303114d0822b8cf70805a8a447986a7762 Reviewed-on: http://gerrit.openafs.org/6413 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/afs_conn.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index 26e239e08..fcb42609a 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -601,22 +601,8 @@ afs_PutConn(struct afs_conn *ac, struct rx_connection *rxconn, AFS_STATCNT(afs_PutConn); ac->refCount--; if (ac->refCount < 0) { - static int warned = 0; - /* So, someone is 'put'ing more refs than they got. From now on, we - * have no idea if the structure is actually still in use, so just - * set the refcount to a really negative number to make it unlikely - * that the count will ever reach 0 and the conn gets freed. This - * leaks memory, but the alternative is panicing, or risking memory - * corruption. */ - ac->refCount = -10000; - if (!warned) { - warned = 1; - afs_warn("afs_PutConn: negative refCount with 0x%lx; this should " - "not ever happen! Trying to carry on anyway, but please " - "report this issue\n", - (unsigned long)(uintptrsz)ac); - } - return; + osi_Panic("afs_PutConn: refcount imbalance 0x%lx %d", + (unsigned long)(uintptrsz)ac, (int)ac->refCount); } ac->parent->refCount--; rx_PutConnection(rxconn); -- 2.39.5