Module: xenomai-3 Branch: stable-3.0.x Commit: 027898e4732cb5de9b2f1e762a61661ba9421d00 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=027898e4732cb5de9b2f1e762a61661ba9421d00
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Mar 5 15:43:32 2017 +0100 copperplate/heapobj-shared: fix bitmap corruption during allocation --- lib/copperplate/heapobj-pshared.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index 8da4a1f..578f442 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -308,6 +308,16 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) b += r; v >>= r; v |= -1U << (32 - r); + /* + * No more zero bits on the left, and not at + * the leftmost position: any ongoing zero bit + * sequence stops here in the current word, + * short of free bits. Reset the sequence, and + * keep searching for one which is at least + * nrpages-bit long. + */ + if (v == -1U && b < 32) + seq = 0; } } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git