Module: xenomai-3 Branch: wip/heapmem Commit: bd6a419fe1d0e2ee0382baf2ed1db22355abe69b URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bd6a419fe1d0e2ee0382baf2ed1db22355abe69b
Author: Philippe Gerum <r...@xenomai.org> Date: Thu Apr 26 11:03:50 2018 +0200 copperplate/heapobj-pshared: fix reservation in allocation bitmap This is a severe bug which would cause an already reserved page range to be returned twice in specific situations depending on the bitmap contents at the time of the second allocation. --- lib/copperplate/heapobj-pshared.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index a3c5484..d4324df 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -289,8 +289,12 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) */ for (n = 0, seq = 0; n < bitwords; n++) { v = bitmap[n]; + if (v == -1U) { + seq = 0; + continue; + } b = 0; - while (v != -1U) { + for (;;) { r = __ctz(v); if (r) { seq += r; @@ -316,8 +320,11 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) * keep searching for one which is at least * nrpages-bit long. */ - if (v == -1U && b < 32) - seq = 0; + if (v == -1U) { + if (b < 32) + seq = 0; + break; + } } } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git