memdisk: make sure to ignore non-active ranges
authorH. Peter Anvin <hpa@zytor.com>
Fri, 10 Oct 2008 19:47:14 +0000 (12:47 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 13 Oct 2008 19:26:59 +0000 (12:26 -0700)
Skip non-active ranges when looking for a suitable chunk of memory for
decompression.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
memdisk/setup.c

index a52f136..5fc2aa0 100644 (file)
@@ -274,8 +274,8 @@ void unzip_if_needed(uint32_t *where_p, uint32_t *size_p)
   int i, okmem;
 
   /* Is it a gzip image? */
-  if (check_zip ((void *)where, size, &zbytes, &gzdatasize,
-                 &orig_crc, &offset) == 0) {
+  if (check_zip((void *)where, size, &zbytes, &gzdatasize,
+               &orig_crc, &offset) == 0) {
 
     if (offset + zbytes > size) {
       /* Assertion failure; check_zip is supposed to guarantee this
@@ -294,10 +294,13 @@ void unzip_if_needed(uint32_t *where_p, uint32_t *size_p)
       /* Must be memory */
       if ( ranges[i].type != 1 )
        continue;
+      if (!(ranges[i].extattr & 1))
+       continue;
 
       /* Range start */
       if ( ranges[i].start >= 0xFFFFFFFF )
        continue;
+
       startrange = (uint32_t)ranges[i].start;
 
       /* Range end (0 for end means 2^64) */