diff options
author | Daniel Jarai <daniel.jarai@bartec-pixavi.com> | 2018-12-17 15:46:34 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-12-17 15:46:34 -0800 |
commit | c8128f504a5d631624eddea8d804c14fa87df7e0 (patch) | |
tree | f45465d53073e297435a31a76980efc3706669d9 | |
parent | 5341c49b73f07d6cc6b206d77f9c69edd84d17fa (diff) | |
parent | 4e96a70f33933c2cab08d54e3fc57d3bb694ce96 (diff) | |
download | device_google_contexthub-c8128f504a5d631624eddea8d804c14fa87df7e0.tar.gz device_google_contexthub-c8128f504a5d631624eddea8d804c14fa87df7e0.tar.bz2 device_google_contexthub-c8128f504a5d631624eddea8d804c14fa87df7e0.zip |
nanohub: hostIntf: handle memory allocation failures am: 8880b72751 am: 6cac791c88
am: 4e96a70f33
Change-Id: I4a69874df86e2c5b82ea754f6e952b8e3eeb4e92
-rw-r--r-- | firmware/os/core/hostIntf.c | 11 |
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++) { |