Selaa lähdekoodia

[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().
tags/v0.9.7
Michael Brown 15 vuotta sitten
vanhempi
commit
46da51703a
1 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 3
    3
      src/arch/i386/interface/pcbios/memtop_umalloc.c

+ 3
- 3
src/arch/i386/interface/pcbios/memtop_umalloc.c Näytä tiedosto

92
 		}
92
 		}
93
 	}
93
 	}
94
 
94
 
95
-	if ( ! top ) {
95
+	if ( ! heap_size ) {
96
 		DBG ( "No external heap available\n" );
96
 		DBG ( "No external heap available\n" );
97
 		return -ENOMEM;
97
 		return -ENOMEM;
98
 	}
98
 	}
139
 	int rc;
139
 	int rc;
140
 
140
 
141
 	/* Initialise external memory allocator if necessary */
141
 	/* Initialise external memory allocator if necessary */
142
-	if ( ! top  ) {
142
+	if ( bottom == top ) {
143
 		if ( ( rc = init_eheap() ) != 0 )
143
 		if ( ( rc = init_eheap() ) != 0 )
144
-			return rc;
144
+			return UNULL;
145
 	}
145
 	}
146
 
146
 
147
 	/* Get block properties into extmem */
147
 	/* Get block properties into extmem */

Loading…
Peruuta
Tallenna