]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
malloc: solve dead code issue in memalign()
authorStephen Warren <swarren@nvidia.com>
Thu, 4 Feb 2016 18:54:20 +0000 (11:54 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 8 Feb 2016 15:22:38 +0000 (10:22 -0500)
The recent change to memalign() caused the allocation failure detection
code to be dead code; the "retry" logic is always activated under the same
condition that the original failure detection code is, and also fully
handles any possible failures. This patch solves the presence of dead
code.

Two alternatives are possible:

a) Delete the now-dead test, and rely on the "retry" path to handle any
allocation problems, as it does.

b) Make the "retry" path fall through to the existing (currently dead)
failure detection code, thus making it not-dead.

(b) was chosen since it reduces the diff between U-Boot's and the upstream
dlmalloc. This should make it marginally easier to import a new version of
dlmalloc in the future.

Reported by: Coverity Scan
Fixes: 4f144a416469 ("malloc: work around some memalign fragmentation issues")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/dlmalloc.c

index 2b964d16b11e11e96a83c9b31e9ddee681bda8c3..5ea37dfb6e4c334db262b6726bfff0e1d5362508 100644 (file)
@@ -2848,7 +2848,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
       return m;
     /* Otherwise, fail */
     fREe(m);
-    return NULL;
+    m = NULL;
   }
 
   if (m == NULL) return NULL; /* propagate failure */