summaryrefslogtreecommitdiff
path: root/common/shmalloc.c
diff options
context:
space:
mode:
authorGurleen Grewal <gurleengrewal@google.com>2019-09-12 14:49:29 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-17 16:27:55 +0000
commit4284bf8c73aa210cb997d39a14851c5505a9c90b (patch)
tree14b82762e7ee3f1a91224e1f83829270cda4eb66 /common/shmalloc.c
parentaa771bf3d3610477d5f359e43f873084201203a4 (diff)
downloadchrome-ec-4284bf8c73aa210cb997d39a14851c5505a9c90b.tar.gz
Change get_shmem_size() to max allocatable bytes
BUG=b/140066993 TEST=run "make buidall" and verify that test nvmem passed, In cr50 console: "flashread 0 7000" should succeed Change-Id: If3979559da5d61c27bbca7639a220fca862bbc91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1802158 Tested-by: Gurleen Grewal <gurleengrewal@chromium.org> Tested-by: Gurleen Grewal <gurleengrewal@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
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;
}