diff options
author | Angela Stegmaier <angelabaker@ti.com> | 2016-06-23 16:16:01 -0500 |
---|---|---|
committer | Angela Stegmaier <angelabaker@ti.com> | 2016-06-29 13:44:44 -0500 |
commit | 91e0975942067ce816125dcfe8a6f42b13e43659 (patch) | |
tree | 7b7e43cfcaa1d3f287d554adcaf3a9dac7c30ec6 | |
parent | a61d10f5dac77b532375f438239f07c795c7a220 (diff) | |
download | ipc-91e0975942067ce816125dcfe8a6f42b13e43659.tar.gz |
Linux: GateMP_daemon: Fix incorrect mapping of IGateProvider_NULL
In the case that IGateProvider_NULL is used for one of the remoteCustom
gates, the code will anyway attempt to map it and throw and error trace.
The code continues as this is the last part of the attach and the error
is essentially ignored as part of the design of GateMP support in order
to allow the LAD daemon to continue even if the setup fails. So the error
trace doesn't cause any functionality failure.
Fix up the code so that mappings are only done when there is a valid
size, so that the valid case of IGateProvider_NULL is properly handled.
Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
-rw-r--r-- | linux/src/daemon/GateMP_daemon.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/linux/src/daemon/GateMP_daemon.c b/linux/src/daemon/GateMP_daemon.c index 56b2ad6..56ab580 100644 --- a/linux/src/daemon/GateMP_daemon.c +++ b/linux/src/daemon/GateMP_daemon.c @@ -254,25 +254,31 @@ Int GateMP_attach(UInt16 procId) offset = nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1); offset -= baseaddr; + if (size > 0) { #if defined(IPC_BUILDOS_ANDROID) - GateMP_module->remoteSystemInUse = mmap64(NULL, size, - (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, - (off64_t)offset); + GateMP_module->remoteSystemInUse = mmap64(NULL, size, + (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, + (off64_t)offset); #else - GateMP_module->remoteSystemInUse = mmap(NULL, size, - (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, - (off_t)offset); + GateMP_module->remoteSystemInUse = mmap(NULL, size, + (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, + (off_t)offset); #endif - if (GateMP_module->remoteSystemInUse == MAP_FAILED) { - LOG1("Failed to map remoteSystemInUse=0x%p to host address" \ - " space!", GateMP_module->remoteSystemInUse); - GateMP_module->remoteSystemInUse = NULL; - status = GateMP_E_MEMORY; + if (GateMP_module->remoteSystemInUse == MAP_FAILED) { + LOG1("Failed to map remoteSystemInUse=0x%p to host address" \ + " space!", GateMP_module->remoteSystemInUse); + GateMP_module->remoteSystemInUse = NULL; + status = GateMP_E_MEMORY; + } + else { + alignDiff = nsValue[0] - baseaddr - offset; + GateMP_module->remoteSystemInUse = + GateMP_module->remoteSystemInUse + alignDiff; + } } else { - alignDiff = nsValue[0] - baseaddr - offset; - GateMP_module->remoteSystemInUse = - GateMP_module->remoteSystemInUse + alignDiff; + LOG0("Invalid configuration for remoteSystem gate"); + status = GateMP_E_FAIL; } size = GateMP_module->numRemoteCustom1 * sizeof (UInt8) + @@ -281,7 +287,7 @@ Int GateMP_attach(UInt16 procId) offset = nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1); offset -= baseaddr; - if (status == GateMP_S_SUCCESS) { + if ((status == GateMP_S_SUCCESS) && (size > 0)) { #if defined(IPC_BUILDOS_ANDROID) GateMP_module->remoteCustom1InUse = mmap64(NULL, size, (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, @@ -310,7 +316,7 @@ Int GateMP_attach(UInt16 procId) offset = nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1); offset -= baseaddr; - if (status == GateMP_S_SUCCESS) { + if ((status == GateMP_S_SUCCESS) && (size > 0)) { #if defined(IPC_BUILDOS_ANDROID) GateMP_module->remoteCustom2InUse = mmap64(NULL, size, (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, |