All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/3] bap: Update bt_bap user data handling
@ 2025-02-20  8:58 Iulia Tanasescu
  2025-02-20  8:58 ` [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap Iulia Tanasescu
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Iulia Tanasescu @ 2025-02-20  8:58 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

For the BAP Broadcast Assistant/Scan Delegator implementation
(BASS Client/Server), BAP sessions with Broadcasters are notified
in the bap_attached/bap_detached callbacks registered by BASS.
The associated btd_service must be available in the bt_bap
user data, to match the session with the Broadcaster device.

This patch updates the way bt_bap user data is handled, to ensure
the above.

Iulia Tanasescu (3):
  bap: Do not clear user_data before detaching bt_bap
  bap: Do not set adapter as bt_bap user_data
  bass: Add checks for bap user data

 profiles/audio/bap.c  |  5 +----
 profiles/audio/bass.c | 23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)


base-commit: 264bf951f2d687f520898fa3e182291f1261e3a7
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap
  2025-02-20  8:58 [PATCH BlueZ 0/3] bap: Update bt_bap user data handling Iulia Tanasescu
@ 2025-02-20  8:58 ` Iulia Tanasescu
  2025-02-20 10:11   ` bap: Update bt_bap user data handling bluez.test.bot
  2025-02-20  8:58 ` [PATCH BlueZ 2/3] bap: Do not set adapter as bt_bap user_data Iulia Tanasescu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Iulia Tanasescu @ 2025-02-20  8:58 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

After detaching a bt_bap session, each plugin that registered a bap
detached callback will be notified. The bt_bap user data should be
set when calling these callbacks, so the bt_bap session can be
matched to the associated service and the cleanup is handled
accordingly.
---
 profiles/audio/bap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index c503f250c..6d2afa2c0 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -192,10 +192,8 @@ static void bap_data_free(struct bap_data *data)
 	if (data->io_id)
 		g_source_remove(data->io_id);
 
-	if (data->service && btd_service_get_user_data(data->service) == data) {
+	if (data->service && btd_service_get_user_data(data->service) == data)
 		btd_service_set_user_data(data->service, NULL);
-		bt_bap_set_user_data(data->bap, NULL);
-	}
 
 	queue_destroy(data->snks, ep_unregister);
 	queue_destroy(data->srcs, ep_unregister);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 2/3] bap: Do not set adapter as bt_bap user_data
  2025-02-20  8:58 [PATCH BlueZ 0/3] bap: Update bt_bap user data handling Iulia Tanasescu
  2025-02-20  8:58 ` [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap Iulia Tanasescu
@ 2025-02-20  8:58 ` Iulia Tanasescu
  2025-02-20  8:58 ` [PATCH BlueZ 3/3] bass: Add checks for bap user data Iulia Tanasescu
  2025-02-21 16:50 ` [PATCH BlueZ 0/3] bap: Update bt_bap user data handling patchwork-bot+bluetooth
  3 siblings, 0 replies; 6+ messages in thread
From: Iulia Tanasescu @ 2025-02-20  8:58 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

In case of a BAP Broadcast Source session, it is not necessary to set the
adapter as bt_bap user data. Plus, setting it makes it confusing for
plugins to know the type of pointer to parse, distinguishing between
Broadcast Source sessions and other types of sessions that hold a service
reference as user data.

For a BAP Broadcast Source, the bt_bap user data can remain unset, since
the session is not associated with any remote device/service.
---
 profiles/audio/bap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 6d2afa2c0..b36e45ea4 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -3280,7 +3280,6 @@ static int bap_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter)
 	data->pac_id = bt_bap_pac_register(data->bap, pac_added_broadcast,
 					pac_removed_broadcast, data, NULL);
 
-	bt_bap_set_user_data(data->bap, adapter);
 	bap_data_set_user_data(data, adapter);
 
 	data->adapter = adapter;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 3/3] bass: Add checks for bap user data
  2025-02-20  8:58 [PATCH BlueZ 0/3] bap: Update bt_bap user data handling Iulia Tanasescu
  2025-02-20  8:58 ` [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap Iulia Tanasescu
  2025-02-20  8:58 ` [PATCH BlueZ 2/3] bap: Do not set adapter as bt_bap user_data Iulia Tanasescu
@ 2025-02-20  8:58 ` Iulia Tanasescu
  2025-02-21 16:50 ` [PATCH BlueZ 0/3] bap: Update bt_bap user data handling patchwork-bot+bluetooth
  3 siblings, 0 replies; 6+ messages in thread
From: Iulia Tanasescu @ 2025-02-20  8:58 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
	luiz.dentz, Iulia Tanasescu

This adds checks before parsing bt_bap user data in bap attached/detached,
to avoid accessing NULL pointers in case the user data has been cleared
or has not been set before attaching a BAP session.
---
 profiles/audio/bass.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index 6c84fa1c3..67ee847b8 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -559,14 +559,21 @@ static void confirm_cb(GIOChannel *io, void *user_data)
 
 static void bap_attached(struct bt_bap *bap, void *user_data)
 {
-	struct btd_service *service = bt_bap_get_user_data(bap);
-	struct btd_device *device = btd_service_get_device(service);
-	struct btd_adapter *adapter = device_get_adapter(device);
+	struct btd_service *service;
+	struct btd_device *device;
+	struct btd_adapter *adapter;
 	struct bass_delegator *dg;
 	GError *err = NULL;
 
 	DBG("%p", bap);
 
+	service = bt_bap_get_user_data(bap);
+	if (!service)
+		return;
+
+	device = btd_service_get_device(service);
+	adapter = device_get_adapter(device);
+
 	dg = queue_find(delegators, delegator_match_device, device);
 	if (!dg)
 		/* Only probe devices added via Broadcast Assistants */
@@ -620,12 +627,18 @@ static void setup_free(void *data)
 
 static void bap_detached(struct bt_bap *bap, void *user_data)
 {
-	struct btd_service *service = bt_bap_get_user_data(bap);
-	struct btd_device *device = btd_service_get_device(service);
+	struct btd_service *service;
+	struct btd_device *device;
 	struct bass_delegator *dg;
 
 	DBG("%p", bap);
 
+	service = bt_bap_get_user_data(bap);
+	if (!service)
+		return;
+
+	device = btd_service_get_device(service);
+
 	dg = queue_remove_if(delegators, delegator_match_device, device);
 	if (!dg)
 		return;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: bap: Update bt_bap user data handling
  2025-02-20  8:58 ` [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap Iulia Tanasescu
@ 2025-02-20 10:11   ` bluez.test.bot
  0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-02-20 10:11 UTC (permalink / raw)
  To: linux-bluetooth, iulia.tanasescu

[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=935909

---Test result---

Test Summary:
CheckPatch                    PENDING   0.22 seconds
GitLint                       PENDING   0.18 seconds
BuildEll                      PASS      20.51 seconds
BluezMake                     PASS      1530.47 seconds
MakeCheck                     PASS      13.76 seconds
MakeDistcheck                 PASS      159.59 seconds
CheckValgrind                 PASS      222.09 seconds
CheckSmatch                   PASS      286.40 seconds
bluezmakeextell               PASS      98.96 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      877.71 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ 0/3] bap: Update bt_bap user data handling
  2025-02-20  8:58 [PATCH BlueZ 0/3] bap: Update bt_bap user data handling Iulia Tanasescu
                   ` (2 preceding siblings ...)
  2025-02-20  8:58 ` [PATCH BlueZ 3/3] bass: Add checks for bap user data Iulia Tanasescu
@ 2025-02-21 16:50 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2025-02-21 16:50 UTC (permalink / raw)
  To: Iulia Tanasescu
  Cc: linux-bluetooth, claudia.rosu, mihai-octavian.urzica,
	andrei.istodorescu, luiz.dentz

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 20 Feb 2025 10:58:08 +0200 you wrote:
> For the BAP Broadcast Assistant/Scan Delegator implementation
> (BASS Client/Server), BAP sessions with Broadcasters are notified
> in the bap_attached/bap_detached callbacks registered by BASS.
> The associated btd_service must be available in the bt_bap
> user data, to match the session with the Broadcaster device.
> 
> This patch updates the way bt_bap user data is handled, to ensure
> the above.
> 
> [...]

Here is the summary with links:
  - [BlueZ,1/3] bap: Do not clear user_data before detaching bt_bap
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=790a0c5d75ec
  - [BlueZ,2/3] bap: Do not set adapter as bt_bap user_data
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cfb233b4c6b3
  - [BlueZ,3/3] bass: Add checks for bap user data
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fefeb495dd22

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-21 16:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20  8:58 [PATCH BlueZ 0/3] bap: Update bt_bap user data handling Iulia Tanasescu
2025-02-20  8:58 ` [PATCH BlueZ 1/3] bap: Do not clear user_data before detaching bt_bap Iulia Tanasescu
2025-02-20 10:11   ` bap: Update bt_bap user data handling bluez.test.bot
2025-02-20  8:58 ` [PATCH BlueZ 2/3] bap: Do not set adapter as bt_bap user_data Iulia Tanasescu
2025-02-20  8:58 ` [PATCH BlueZ 3/3] bass: Add checks for bap user data Iulia Tanasescu
2025-02-21 16:50 ` [PATCH BlueZ 0/3] bap: Update bt_bap user data handling patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.