Page MenuHomeFreeBSD

D31158.id.diff
No OneTemporary

D31158.id.diff

diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c
--- a/sys/kern/subr_blist.c
+++ b/sys/kern/subr_blist.c
@@ -244,8 +244,16 @@
* Calculate the radix and node count used for scanning.
*/
nodes = 1;
- for (radix = 1; radix <= blocks / BLIST_RADIX; radix *= BLIST_RADIX)
- nodes += 1 + (blocks - 1) / radix / BLIST_RADIX;
+ for (radix = 1; (blocks - 1) / BLIST_RADIX / radix > 0;
+ radix *= BLIST_RADIX)
+ nodes += 1 + (blocks - 1) / BLIST_RADIX / radix;
+
+ /*
+ * Include a sentinel node to ensure that cross-leaf scans stay within
+ * the bounds of the allocation.
+ */
+ if (blocks % BLIST_RADIX == 0)
+ nodes++;
bl = malloc(offsetof(struct blist, bl_root[nodes]), M_SWAP, flags |
M_ZERO);

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 6, 9:58 PM (3 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38261319
Default Alt Text
D31158.id.diff (729 B)

Event Timeline