summaryrefslogtreecommitdiff
path: root/android/hal-bluetooth.c
diff options
context:
space:
mode:
authorAtul Rai <a.rai@samsung.com>2015-06-29 12:14:13 +0530
committerSzymon Janc <szymon.janc@tieto.com>2015-07-27 21:19:22 +0200
commit0bd5677f92c072dc5e038dda33e5d9c1591b68ab (patch)
treed7b977c4f6a74d5890cb08eca2996b3adfc91b86 /android/hal-bluetooth.c
parent360ecd96fed73867e7b96ab06a6f8ac390ec814a (diff)
downloadbluez-0bd5677f92c072dc5e038dda33e5d9c1591b68ab.tar.gz
android/hal-bluetooth: Fix NULL ptr dereference
Add NULL check on malloc return to fix NULL pointer dereference in case malloc fails.
Diffstat (limited to 'android/hal-bluetooth.c')
-rw-r--r--android/hal-bluetooth.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index e24f7d2af..66f4a3774 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <cutils/properties.h>
@@ -1103,6 +1104,11 @@ static int open_bluetooth(const struct hw_module_t *module, char const *name,
DBG("");
+ if (!dev) {
+ error("Failed to allocate memory for device");
+ return -ENOMEM;
+ }
+
memset(dev, 0, sizeof(bluetooth_device_t));
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.version = 0;