summaryrefslogtreecommitdiff
path: root/common/shmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/shmalloc.c')
-rw-r--r--common/shmalloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/shmalloc.c b/common/shmalloc.c
index 8c66a63eb8..5cf9556fce 100644
--- a/common/shmalloc.c
+++ b/common/shmalloc.c
@@ -213,7 +213,7 @@ static int do_acquire(int size, struct shm_buffer **dest_ptr)
pfb = free_buf_chain;
while (pfb) {
- if ((pfb->buffer_size > size) &&
+ if ((pfb->buffer_size >= size) &&
((pfb->buffer_size - size) < headroom)) {
/* this is a new candidate. */
headroom = pfb->buffer_size - size;
@@ -302,6 +302,8 @@ int shared_mem_size(void)
}
mutex_unlock(&shmem_lock);
+ /* Leave room for shmem header */
+ max_available -= sizeof(struct shm_buffer);
return max_available;
}