git: 06134ea2f38c - main - malloc(9): Check for M_NEVERFREED
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 05 Aug 2024 16:46:28 UTC
The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=06134ea2f38ca214b53a1613e110e8332b2804e4 commit 06134ea2f38ca214b53a1613e110e8332b2804e4 Author: Bojan Novković <bnovkov@FreeBSD.org> AuthorDate: 2024-07-31 17:43:31 +0000 Commit: Bojan Novković <bnovkov@FreeBSD.org> CommitDate: 2024-08-05 16:44:10 +0000 malloc(9): Check for M_NEVERFREED The recently introduced M_NEVERFREED flag is not meant to be used for regular malloc requests. Enforce this by checking for M_NEVERFREED in malloc_dbg. Reviewed by: alc, kib, markj Differential Revision: https://reviews.freebsd.org/D46199 --- sys/kern/kern_malloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 3c4cb63003c4..9d7e0464e0f7 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -542,6 +542,8 @@ malloc_dbg(caddr_t *vap, size_t *sizep, struct malloc_type *mtp, once++; } } + KASSERT((flags & M_NEVERFREED) == 0, + ("malloc: M_NEVERFREED is for internal use only")); #endif #ifdef MALLOC_MAKE_FAILURES if ((flags & M_NOWAIT) && (malloc_failure_rate != 0)) {