linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/2] shared/gatt-client: Reset callbacks when unregistering
Date: Fri,  9 Feb 2018 12:53:15 +0200	[thread overview]
Message-ID: <20180209105315.24862-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20180209105315.24862-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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.
---
 src/shared/gatt-client.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 8083ff719..1285c37ef 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1212,7 +1212,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,
@@ -3157,6 +3159,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;
 }
-- 
2.14.3


  parent reply	other threads:[~2018-02-09 10:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 10:53 [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering Luiz Augusto von Dentz
2018-02-09 10:53 ` Luiz Augusto von Dentz [this message]
2018-02-12 11:28   ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180209105315.24862-3-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).