diff options
author | David Greenman <dg@FreeBSD.org> | 1995-03-11 22:28:16 +0000 |
---|---|---|
committer | David Greenman <dg@FreeBSD.org> | 1995-03-11 22:28:16 +0000 |
commit | 17dda4c92966b4f7b56dc1d707f089634b47d7e8 (patch) | |
tree | 46cfa4a863f4f4669bebb87449527f2bc671cc34 /sys | |
parent | a14e8fd0323f6ef03f365590fccde7667c6d73ea (diff) | |
download | src-17dda4c92966b4f7b56dc1d707f089634b47d7e8.tar.gz src-17dda4c92966b4f7b56dc1d707f089634b47d7e8.zip |
Added some additional DIAGNOSTIC code that makes sure that freed
memory addresses and types are with the valid range. Increased
MAX_COPY to 256 (used to verify no freed memory use with DIAGNOSTIC).
Notes
Notes:
svn path=/head/; revision=7009
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_malloc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index dc60c5b0de5d..17d8194879ea 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 - * $Id: kern_malloc.c,v 1.7 1995/01/09 16:04:50 davidg Exp $ + * $Id: kern_malloc.c,v 1.8 1995/02/02 08:49:07 davidg Exp $ */ #include <sys/param.h> @@ -65,7 +65,7 @@ long addrmask[] = { 0, * that modifications after frees can be detected. */ #define WEIRD_ADDR 0xdeadbeef -#define MAX_COPY 32 +#define MAX_COPY 256 /* * Normally the first word of the structure is used to hold the list @@ -263,6 +263,16 @@ free(addr, type) register struct kmemstats *ksp = &kmemstats[type]; #endif +#ifdef DIAGNOSTIC + if ((char *)addr < kmembase || (char *)addr >= kmemlimit) { + printf("free: address 0x%x out of range\n", addr); + panic("free: bogus address"); + } + if ((u_long)type > M_LAST) { + printf("free: type %d out of range\n", type); + panic("free: bogus type"); + } +#endif kup = btokup(addr); size = 1 << kup->ku_indx; kbp = &bucket[kup->ku_indx]; |