shared/gatt-client: Reset callbacks when unregistering 99/204899/1
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 9 Feb 2018 10:46:55 +0000 (12:46 +0200)
committerAmit Purwar <amit.purwar@samsung.com>
Mon, 15 Apr 2019 03:26:31 +0000 (08:56 +0530)
If user application is unregistering a notification handler its
callbacks shall not be called even CCC write is still holding a
reference to notify_data.

Change-Id: Ib16702e9d0437478487daf6571844b55ceac5266
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
src/shared/gatt-client.c

index 7cafa97..fe86689 100644 (file)
@@ -1387,7 +1387,9 @@ static void complete_notify_request(void *data)
        struct notify_data *notify_data = data;
 
        notify_data->att_id = 0;
-       notify_data->callback(0, notify_data->user_data);
+
+       if (notify_data->callback)
+               notify_data->callback(0, notify_data->user_data);
 }
 
 static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
@@ -3528,6 +3530,10 @@ bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client,
        /* Remove data if it has been queued */
        queue_remove(notify_data->chrc->reg_notify_queue, notify_data);
 
+       /* Reset callbacks */
+       notify_data->callback = NULL;
+       notify_data->notify = NULL;
+
        complete_unregister_notify(notify_data);
        return true;
 }