diff options
author | Kevin Kirspel <kevin-kirspel@idexx.com> | 2017-06-29 10:36:43 -0400 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2017-07-14 16:04:05 -0400 |
commit | c6bb1c33bcf70d1398073c96a4fac4f9b031b9ab (patch) | |
tree | ce904d8bfaded9060edf71bac28c517c3e75a4c8 /cpukit/posix/src/munmap.c | |
parent | bsps: Include missing header file (diff) | |
download | rtems-c6bb1c33bcf70d1398073c96a4fac4f9b031b9ab.tar.bz2 |
posix/mmap: Add support for file handler and MAP_ANON
Added a mmap file handler to struct _rtems_filesystem_file_handlers_r.
Updated each file handler object to support the default mmap handler.
Updated mmap() to call the mmap handler for MAP_SHARED.
Added a mmap file handler for shm
Added support for MAP_ANON in mmap().
Updates #2859
Diffstat (limited to 'cpukit/posix/src/munmap.c')
-rw-r--r-- | cpukit/posix/src/munmap.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cpukit/posix/src/munmap.c b/cpukit/posix/src/munmap.c index 323a24e6f4..2d812ae041 100644 --- a/cpukit/posix/src/munmap.c +++ b/cpukit/posix/src/munmap.c @@ -46,6 +46,12 @@ int munmap(void *addr, size_t len) return -1; } + /* Check for illegal addresses. Watch out for address wrap. */ + if (addr + len < addr) { + errno = EINVAL; + return -1; + } + /* * Obtain the mmap lock. Sets errno on failure. */ @@ -63,9 +69,11 @@ int munmap(void *addr, size_t len) if ( mapping->is_shared_shm == true ) { shm_munmap(mapping->iop); } - refcnt = rtems_libio_decrement_mapping_refcnt(mapping->iop); - if ( refcnt == 0 ) { - rtems_libio_check_deferred_free(mapping->iop); + if ( mapping->iop != NULL ) { + refcnt = rtems_libio_decrement_mapping_refcnt(mapping->iop); + if ( refcnt == 0 ) { + rtems_libio_check_deferred_free(mapping->iop); + } } /* only free the mapping address for non-fixed mapping */ if (( mapping->flags & MAP_FIXED ) != MAP_FIXED ) { |