summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>1999-04-05 04:02:09 +0000
committergrog <grog@FreeBSD.org>1999-04-05 04:02:09 +0000
commit549cf0169041b2234865474184b34f315ba432dd (patch)
tree0c9af71ce99e215c937ae00dd1c4928f7bd9280e /sys
parentec96761e24dc3396038df18a60895a6ff653ea13 (diff)
downloadFreeBSD-src-549cf0169041b2234865474184b34f315ba432dd.zip
FreeBSD-src-549cf0169041b2234865474184b34f315ba432dd.tar.gz
free_vinum: Clean out bdevsw entry before unloading kld.
Repeatedly-tripped-over-by: Vallo Kallaste <vallo@matti.ee> When VINUMDEBUG is set, free any memory found still allocated. Only log errors if DEBUG_EXITFREE is set.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/vinum/vinum.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/dev/vinum/vinum.c b/sys/dev/vinum/vinum.c
index d9621f9..4005124 100644
--- a/sys/dev/vinum/vinum.c
+++ b/sys/dev/vinum/vinum.c
@@ -213,16 +213,31 @@ vinum_modevent(module_t mod, modeventtype_t type, void *unused)
#ifdef VINUMDEBUG
if (total_malloced) {
int i;
-
- for (i = 0; i < malloccount; i++)
- log(LOG_WARNING,
- "vinum: exiting with %d bytes malloced from %s:%d\n",
- malloced[i].size,
- malloced[i].file,
- malloced[i].line);
+ int *poke;
+
+ for (i = 0; i < malloccount; i++) {
+ if (debug & DEBUG_EXITFREE) /* want to hear about them */
+ log(LOG_WARNING,
+ "vinum: exiting with %d bytes malloced from %s:%d\n",
+ malloced[i].size,
+ malloced[i].file,
+ malloced[i].line);
+#ifdef INVARIANTS
+ poke = &((int *) malloced[i].address)
+ [malloced[i].size / (2 * sizeof(int))]; /* middle of the area */
+ if (*poke == 0xdeadc0de) /* already freed */
+ log(LOG_ERR,
+ "vinum: exiting with malloc table inconsistency at %p from %s:%d\n",
+ malloced[i].address,
+ malloced[i].file,
+ malloced[i].line);
+#endif
+ Free(malloced[i].address);
+ }
}
#endif
cdevsw[CDEV_MAJOR] = NULL; /* no cdevsw any more */
+ bdevsw[BDEV_MAJOR] = NULL; /* nor bdevsw */
log(LOG_INFO, "vinum: unloaded\n"); /* tell the world */
return 0;
default:
OpenPOWER on IntegriCloud