mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-12 18:57:55 +00:00
[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().
This commit is contained in:
parent
816a32aaee
commit
46da51703a
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user