[syslinux:firmware] movebits: allow allocation across region boundary

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Jul 18 05:00:10 PDT 2013


Commit-ID:  e94cce1ad1183afa39c1f01e9b49345ddb1a0404
Gitweb:     http://www.syslinux.org/commit/e94cce1ad1183afa39c1f01e9b49345ddb1a0404
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Wed, 17 Jul 2013 16:40:46 +0100
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 17 Jul 2013 22:27:16 +0100

movebits: allow allocation across region boundary

It's OK to allocate across some region boundaries, provided that the
region types are compatible.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/lib/syslinux/movebits.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/com32/lib/syslinux/movebits.c b/com32/lib/syslinux/movebits.c
index 8ffdc63..85852e7 100644
--- a/com32/lib/syslinux/movebits.c
+++ b/com32/lib/syslinux/movebits.c
@@ -142,6 +142,18 @@ static void free_movelist(struct syslinux_movelist **parentptr)
 	delete_movelist(parentptr);
 }
 
+static bool valid_type_combination(enum syslinux_memmap_types type1,
+				   enum syslinux_memmap_types type2)
+{
+    if (type1 != SMT_FREE && type1 != SMT_TERMINAL)
+	return false;
+
+    if (type2 != SMT_FREE && type2 != SMT_TERMINAL)
+	return false;
+
+    return true;
+}
+
 /*
  * Scan the freelist looking for a particular chunk of memory
  */
@@ -167,7 +179,10 @@ static const struct syslinux_memmap *is_free_zone(const struct syslinux_memmap
 		}
 		return NULL;	/* Not free */
 	    } else if (llast >= start) {
-		return NULL;	/* Crosses region boundary */
+		if (valid_type_combination(list->type, list->next->type))
+		    return list;
+
+		return NULL;	/* Crosses incompatible region boundary */
 	    }
 	}
 	list = list->next;


More information about the Syslinux-commits mailing list