You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/01/30 15:22:29 UTC

[incubator-nuttx] branch pr186 updated: fix gran_alloc() miss allocation in mm_granalloc.c.

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch pr186
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/pr186 by this push:
     new 1600980  fix gran_alloc() miss allocation in mm_granalloc.c.
1600980 is described below

commit 1600980a826b1897a5696129fafa22ae417c37cb
Author: minabeoki <mi...@gmail.com>
AuthorDate: Thu Jan 30 23:19:29 2020 +0900

    fix gran_alloc() miss allocation in mm_granalloc.c.
---
 mm/mm_gran/mm_granalloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/mm_gran/mm_granalloc.c b/mm/mm_gran/mm_granalloc.c
index 30794cd..be11d0f 100644
--- a/mm/mm_gran/mm_granalloc.c
+++ b/mm/mm_gran/mm_granalloc.c
@@ -105,8 +105,6 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
 
       /* Now search the granule allocation table for that number of contiguous */
 
-      alloc = priv->heapstart;
-
       for (granidx = 0; granidx < priv->ngranules; granidx += 32)
         {
           /* Get the GAT index associated with the granule table entry */
@@ -118,7 +116,6 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
 
           if (curr == 0xffffffff)
             {
-              alloc += (32 << priv->log2gran);
               continue;
             }
 
@@ -147,6 +144,8 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
            * granules left to satisfy the allocation.
            */
 
+          alloc = priv->heapstart + (granidx << priv->log2gran);
+
           for (bitidx = 0;
                bitidx < 32 && (granidx + bitidx + ngranules) <= priv->ngranules;
               )