summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jarai <daniel.jarai@bartec-pixavi.com>2018-12-17 15:41:28 -0800
committerandroid-build-merger <android-build-merger@google.com>2018-12-17 15:41:28 -0800
commit4e96a70f33933c2cab08d54e3fc57d3bb694ce96 (patch)
tree8b34ceb0b5040abaf7963214906c2928dcf31a42
parent202ee11a1820303f5b02ded09bb50d11cce32d60 (diff)
parent6cac791c88c222c13b8586f64ccf1ce165c3a754 (diff)
downloaddevice_google_contexthub-4e96a70f33933c2cab08d54e3fc57d3bb694ce96.tar.gz
device_google_contexthub-4e96a70f33933c2cab08d54e3fc57d3bb694ce96.tar.bz2
device_google_contexthub-4e96a70f33933c2cab08d54e3fc57d3bb694ce96.zip
nanohub: hostIntf: handle memory allocation failures am: 8880b72751
am: 6cac791c88 Change-Id: I1d43c60e875ba2759736f4aadafc60b5baee1d60
-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++) {