summaryrefslogtreecommitdiff
path: root/plugins/bluetooth.c
diff options
context:
space:
mode:
authorHarish Jenny K N <harish_kandiga@mentor.com>2015-11-24 17:39:50 +0530
committerPatrik Flykt <patrik.flykt@linux.intel.com>2015-11-25 12:38:28 +0200
commit1a5ef7418d2d1dcef8b993360658ab44ac2a6c53 (patch)
treef3cf33e33772e01dba339f3289d26584663c5298 /plugins/bluetooth.c
parent884a5155bd13f6e3e36734c2bd42e5bbd67c9b05 (diff)
downloadconnman-1a5ef7418d2d1dcef8b993360658ab44ac2a6c53.tar.gz
bluetooth: Fix crash when adapter is NULL
This fixes a crash in pan_create_nap function when proxy_get_string returns NULL for "Adapter". The Backtrace: update_properties ->add_property -->pan_create_nap --->g_hash_table_lookup ---->g_str_hash R0: 00000000 indicating NULL is passed to g_str_hash This patch handles the crash by adding NULL check before passing it to g_hash_table_lookup.
Diffstat (limited to 'plugins/bluetooth.c')
-rw-r--r--plugins/bluetooth.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 45cc3194..6e4febad 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -337,6 +337,7 @@ static void pan_create_nap(struct bluetooth_pan *pan)
{
struct connman_device *device;
const char* role;
+ const char *adapter;
role = proxy_get_role(pan->btdevice_proxy);
if (!role) {
@@ -344,8 +345,12 @@ static void pan_create_nap(struct bluetooth_pan *pan)
return;
}
- device = g_hash_table_lookup(devices,
- proxy_get_string(pan->btdevice_proxy, "Adapter"));
+ adapter = proxy_get_string(pan->btdevice_proxy, "Adapter");
+
+ if (!adapter)
+ return;
+
+ device = g_hash_table_lookup(devices, adapter);
if (!device || !connman_device_get_powered(device))
return;