Skip to contentSkip to conversation

media: Fix registering PAC endpoints if ISO socket are not supported

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Aug 30, 2022 – Aug 31, 2022 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 media: Fix registering PAC endpoints if ISO socket are not supported

From: Luiz Augusto von Dentz <[email protected]>

If adapter don't support ISO sockets the PAC UUIDs shall not be allowed to be registered as they depend on ISO sockets to work properly.

---
 profiles/audio/media.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
profiles/audio/media.c +11 -4
index 85278a6d9be4..a7fa85d60310 100644
@@ -1254,20 +1254,23 @@ static bool endpoint_properties_get(const char *uuid,
 	return true;
 }
 
-static bool endpoint_supported(void)
+static bool endpoint_supported(struct btd_adapter *adapter)
 {
 	return true;
 }
 
-static bool experimental_endpoint_supported(void)
+static bool experimental_endpoint_supported(struct btd_adapter *adapter)
 {
+	if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET))
+		return false;
+
 	return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
 }
 
 static struct media_endpoint_init {
 	const char *uuid;
 	bool (*func)(struct media_endpoint *endpoint, int *err);
-	bool (*supported)(void);
+	bool (*supported)(struct btd_adapter *adapter);
 } init_table[] = {
 	{ A2DP_SOURCE_UUID, endpoint_init_a2dp_source, endpoint_supported },
 	{ A2DP_SINK_UUID, endpoint_init_a2dp_sink, endpoint_supported },
@@ -1315,6 +1318,9 @@ media_endpoint_create(struct media_adapter *adapter,
 	for (i = 0; i < ARRAY_SIZE(init_table); i++) {
 		init = &init_table[i];
 
+		if (!init->supported(adapter->btd_adapter))
+			continue;
+
 		if (!strcasecmp(init->uuid, uuid)) {
 			succeeded = init->func(endpoint, err);
 			break;
@@ -2971,6 +2977,7 @@ static const GDBusMethodTable media_methods[] = {
 static gboolean supported_uuids(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
+	struct media_adapter *adapter = data;
 	DBusMessageIter entry;
 	size_t i;
 
@@ -2980,7 +2987,7 @@ static gboolean supported_uuids(const GDBusPropertyTable *property,
 	for (i = 0; i < ARRAY_SIZE(init_table); i++) {
 		struct media_endpoint_init *init = &init_table[i];
 
-		if (init->supported())
+		if (init->supported(adapter->btd_adapter))
 			dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
 							&init->uuid);
 	}
Signature · 1 line
2.37.2
#1 lore raw

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=672619

---Test result---

Test Summary:

CheckPatch                    PASS      1.17 seconds
GitLint                       PASS      0.80 seconds
Prep - Setup ELL              PASS      26.48 seconds
Build - Prep                  PASS      0.67 seconds
Build - Configure             PASS      8.22 seconds
Build - Make                  PASS      727.87 seconds
Make Check                    PASS      11.61 seconds
Make Check w/Valgrind         PASS      285.48 seconds
Make Distcheck                PASS      236.43 seconds
Build w/ext ELL - Configure   PASS      8.25 seconds
Build w/ext ELL - Make        PASS      82.57 seconds
Incremental Build w/ patches  PASS      0.00 seconds
Scan Build                    WARNING   482.95 seconds

Details
##############################
Test: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches. Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
profiles/audio/media.c:1465:6: warning: 8th function call argument is an uninitialized value
if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3012:3: warning: Use of memory after it is freed

                release_endpoint(adapter->endpoints->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3015:3: warning: Use of memory after it is freed
                media_player_destroy(adapter->players->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3 warnings generated.

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Tue, 30 Aug 2022 14:54:44 -0700 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

If adapter don't support ISO sockets the PAC UUIDs shall not be allowed to be registered as they depend on ISO sockets to work properly.

---
 profiles/audio/media.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Here is the summary with links:
- [BlueZ] media: Fix registering PAC endpoints if ISO socket are not supported

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a84aa0e6e5e7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html