summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jarai <daniel.jarai@bartec-pixavi.com>2018-12-17 15:35:59 -0800
committerandroid-build-merger <android-build-merger@google.com>2018-12-17 15:35:59 -0800
commit6cac791c88c222c13b8586f64ccf1ce165c3a754 (patch)
tree8b34ceb0b5040abaf7963214906c2928dcf31a42
parentaae766a0aae4ddf258cd3b5a9392c2ff10d6342b (diff)
parent8880b727517b86b5472684d1330dc1c01449ce69 (diff)
downloadcontexthub-6cac791c88c222c13b8586f64ccf1ce165c3a754.tar.gz
nanohub: hostIntf: handle memory allocation failures
am: 8880b72751 Change-Id: I10b46d1eeefe586bc86c003c647691456063efaa
-rw-r--r--firmware/os/core/hostIntf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/firmware/os/core/hostIntf.c b/firmware/os/core/hostIntf.c
index ccd571d8..c1d3cd0a 100644
--- a/firmware/os/core/hostIntf.c
+++ b/firmware/os/core/hostIntf.c
@@ -739,7 +739,18 @@ static bool initSensors()
}
mOutputQ = simpleQueueAlloc(totalBlocks, sizeof(struct HostIntfDataBuffer), queueDiscard);
+ if (!mOutputQ) {
+ osLog(LOG_ERROR, "initSensors: failed to allocate data buffer queue!\n");
+ return false;
+ }
+
mActiveSensorTable = heapAlloc(numSensors * sizeof(struct ActiveSensor));
+ if (!mActiveSensorTable) {
+ osLog(LOG_ERROR, "initSensors: failed to allocate active sensor table!\n");
+ simpleQueueDestroy(mOutputQ);
+ return false;
+ }
+
memset(mActiveSensorTable, 0x00, numSensors * sizeof(struct ActiveSensor));
for (i = SENS_TYPE_INVALID; i < SENS_TYPE_LAST_USER; i++) {