From: Luiz Augusto von Dentz Date: Fri, 9 Feb 2018 10:46:55 +0000 (+0200) Subject: shared/gatt-client: Reset callbacks when unregistering X-Git-Tag: accepted/tizen/unified/20190522.085452~1^2~183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F204899%2F1;p=platform%2Fupstream%2Fbluez.git shared/gatt-client: Reset callbacks when unregistering 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 --- diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 7cafa97..fe86689 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -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; }