aboutsummaryrefslogtreecommitdiff
path: root/health
diff options
context:
space:
mode:
authorJose Antonio Santos Cadenas <santoscadenas@gmail.com>2010-11-16 12:50:58 +0100
committerJohan Hedberg <johan.hedberg@nokia.com>2010-11-18 16:56:28 +0200
commitd99c3e454eccae442d2173498c42b593b0b80cf0 (patch)
treeff6726a79d1bc63eb83ec8a4b5b6f8c858eb1058 /health
parentf6322e527e7f8b301fb05e418f71cbd27f16c750 (diff)
downloadbluez-d99c3e454eccae442d2173498c42b593b0b80cf0.tar.gz
Check if the mcl insiede the device is correctly set before use it
Diffstat (limited to 'health')
-rw-r--r--health/hdp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/health/hdp.c b/health/hdp.c
index 72323848..08358c8b 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -813,6 +813,9 @@ static void remove_channels(struct hdp_device *dev)
static void close_device_con(struct hdp_device *dev, gboolean cache)
{
+ if (!dev->mcl)
+ return;
+
mcap_close_mcl(dev->mcl, cache);
dev->mcl_conn = FALSE;
@@ -1152,6 +1155,9 @@ gboolean hdp_set_mcl_cb(struct hdp_device *device, GError **err)
{
gboolean ret;
+ if (!device->mcl)
+ return FALSE;
+
ret = mcap_mcl_set_cb(device->mcl, device, err,
MCAP_MDL_CB_CONNECTED, hdp_mcap_mdl_connected_cb,
MCAP_MDL_CB_CLOSED, hdp_mcap_mdl_closed_cb,
@@ -1757,16 +1763,23 @@ static void device_create_dc_cb(gpointer user_data, GError *err)
return;
}
+ if (!data->dev->mcl) {
+ g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
+ "Mcl was closed");
+ goto fail;
+ }
+
hdp_create_data_ref(data);
if (mcap_create_mdl(data->dev->mcl, data->mdep, data->config,
device_create_mdl_cb, data,
destroy_create_dc_data, &gerr))
return;
+ hdp_create_data_unref(data);
+fail:
reply = g_dbus_create_error(data->msg, ERROR_INTERFACE ".HealthError",
"%s", gerr->message);
- hdp_create_data_unref(data);
g_error_free(gerr);
g_dbus_send_message(data->conn, reply);
}
@@ -1788,7 +1801,7 @@ static DBusMessage *device_echo(DBusConnection *conn,
data->cb = hdp_echo_connect_cb;
hdp_create_data_ref(data);
- if (device->mcl_conn) {
+ if (device->mcl_conn && device->mcl) {
if (mcap_create_mdl(device->mcl, data->mdep, data->config,
device_create_mdl_cb, data,
destroy_create_dc_data, &err))