summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2009-02-15 08:50:23 +0100
committerMichael Brown2009-02-15 08:56:16 +0100
commit46da51703a6f0d213a9b1cbcc4103bb842e2b945 (patch)
treec40b83a42b03e8e682b7a13d2b4868bb7b37fd94 /src
parent[http] Allow for URI encodings within username and password (diff)
downloadipxe-46da51703a6f0d213a9b1cbcc4103bb842e2b945.tar.gz
ipxe-46da51703a6f0d213a9b1cbcc4103bb842e2b945.tar.xz
ipxe-46da51703a6f0d213a9b1cbcc4103bb842e2b945.zip
[umalloc] Avoid problems when _textdata_memsz is a multiple of 4kB
If it happens that _textdata_memsz ends up being an exact multiple of 4kB, then this will cause the .textdata section (after relocation) to start on a page boundary. This means that the hidden memory region (which is rounded down to the nearest page boundary) will start exactly at virtual address 0, i.e. UNULL. This means that init_eheap() will erroneously assume that it has failed to allocate a an external heap, since it typically ends up choosing the area that lies immediately below .textdata, which in this case will be the region with top==UNULL. A subsequent error is that memtop_urealloc() passes through the error return status -ENOMEM to the caller, which (rightly) assumes that the result represents a valid userptr_t address. Fixed by using alternative tests for heap non-existence, and by returning UNULL in case of an error from init_eheap().
Diffstat (limited to 'src')
-rw-r--r--src/arch/i386/interface/pcbios/memtop_umalloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/arch/i386/interface/pcbios/memtop_umalloc.c b/src/arch/i386/interface/pcbios/memtop_umalloc.c
index 2eb7f76d..744d8e30 100644
--- a/src/arch/i386/interface/pcbios/memtop_umalloc.c
+++ b/src/arch/i386/interface/pcbios/memtop_umalloc.c
@@ -92,7 +92,7 @@ static int init_eheap ( void ) {
}
}
- if ( ! top ) {
+ if ( ! heap_size ) {
DBG ( "No external heap available\n" );
return -ENOMEM;
}
@@ -139,9 +139,9 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
int rc;
/* Initialise external memory allocator if necessary */
- if ( ! top ) {
+ if ( bottom == top ) {
if ( ( rc = init_eheap() ) != 0 )
- return rc;
+ return UNULL;
}
/* Get block properties into extmem */