From 03ca213761a72d877d9816dec2c2d0ccc7dae09b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 9 Oct 2017 18:19:06 +0000 Subject: [PATCH] The recent change to initialization of blists (r324420) relied on '-1' appearing only where the code explicitly set it, but since much of the data was not initialized, '-1' appeared other places too, and led to panics. Clear the allocated data before initializing nonzero values by allocating with M_ZERO. Submitted by: Doug Moore Reported by: Oleg V. Nauman , cy Tested by: Oleg V. Nauman MFC after: 1 week X-MFC with: r324420 Differential Revision: https://reviews.freebsd.org/D12627 --- sys/kern/subr_blist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index cc4f818b27d5..0c79448a8400 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -248,7 +248,8 @@ blist_create(daddr_t blocks, int flags) nodes += last_block + 1; last_block /= BLIST_META_RADIX; } - bl = malloc(offsetof(struct blist, bl_root[nodes]), M_SWAP, flags); + bl = malloc(offsetof(struct blist, bl_root[nodes]), M_SWAP, flags | + M_ZERO); if (bl == NULL) return (NULL);