Fixed issue with searching mapped addresses

The loop that checks if the current address is already mapped uses
the same local variable for the chanin node as the newly allocated
chain node so the allocated chain node gets over written.

Added a new local variable for the loop that checks the address

Updates #2859.
This commit is contained in:
Kevin Kirspel
2017-07-19 10:59:16 -04:00
committed by Sebastian Huber
parent 5f1ae90e18
commit bb01a36dfb

View File

@@ -114,6 +114,7 @@ void *mmap(
{ {
struct stat sb; struct stat sb;
mmap_mapping *mapping; mmap_mapping *mapping;
mmap_mapping *current_mapping;
ssize_t r; ssize_t r;
rtems_libio_t *iop; rtems_libio_t *iop;
bool map_fixed; bool map_fixed;
@@ -319,9 +320,9 @@ void *mmap(
* error. POSIX allows us to also return successfully by unmapping * error. POSIX allows us to also return successfully by unmapping
* the overlapping prior mappings. * the overlapping prior mappings.
*/ */
mapping = (mmap_mapping*) node; current_mapping = (mmap_mapping*) node;
if ( ( addr >= mapping->addr ) && if ( ( addr >= current_mapping->addr ) &&
( addr < ( mapping->addr + mapping->len )) ) { ( addr < ( current_mapping->addr + current_mapping->len )) ) {
free( mapping ); free( mapping );
mmap_mappings_lock_release( ); mmap_mappings_lock_release( );
errno = ENXIO; errno = ENXIO;