aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Decotigny <ddecotig@gmail.com>2020-01-14 23:42:05 -0800
committerMichael Brown <mcb30@ipxe.org>2020-07-21 14:51:32 +0100
commit6ec33b8d6cc607579fcc90f551146831890d2070 (patch)
tree3bd2148fce894f95dc04dbed960cd8ceb317d8ff
parent45a0ca6de221f8886a9bfb02f0d34af4fc2f1c5d (diff)
downloadipxe-6ec33b8d6cc607579fcc90f551146831890d2070.zip
ipxe-6ec33b8d6cc607579fcc90f551146831890d2070.tar.gz
ipxe-6ec33b8d6cc607579fcc90f551146831890d2070.tar.bz2
[pcbios] Take alignment into account when checking for available space
Signed-off-by: David Decotigny <ddecotig@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/arch/x86/interface/pcbios/memtop_umalloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c
index d7b8218..1d3f40a 100644
--- a/src/arch/x86/interface/pcbios/memtop_umalloc.c
+++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c
@@ -190,14 +190,14 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
/* Expand/shrink block if possible */
if ( ptr == bottom ) {
/* Update block */
- if ( new_size > ( heap_size + extmem.size ) ) {
- DBG ( "EXTMEM out of space\n" );
- return UNULL;
- }
new = userptr_add ( ptr, - ( new_size - extmem.size ) );
align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) );
new_size += align;
new = userptr_add ( new, -align );
+ if ( new_size > ( heap_size + extmem.size ) ) {
+ DBG ( "EXTMEM out of space\n" );
+ return UNULL;
+ }
DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n",
user_to_phys ( ptr, 0 ),
user_to_phys ( ptr, extmem.size ),