[PATCH BlueZ 1/6] shared/bap: Make bap_get_session public

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes bap_get_session public, so that a reference to the bap session
can be obtained and processed from the BASS plugin, for the Broadcast
Assistant implementation.

In case a session is not found, this commit also adds a NULL check for
the new bap that is created, in case the provided db reference is NULL
and therefore a session fails to be added, to avoid any invalid memory
access.
---
 src/shared/bap.c | 9 ++++++---
 src/shared/bap.h | 2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 4dce32efc..63c4c05c7 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -662,7 +662,7 @@ static void bap_disconnected(int err, void *user_data)
 	bt_bap_detach(bap);
 }
 
-static struct bt_bap *bap_get_session(struct bt_att *att, struct gatt_db *db)
+struct bt_bap *bt_bap_get_session(struct bt_att *att, struct gatt_db *db)
 {
 	const struct queue_entry *entry;
 	struct bt_bap *bap;
@@ -675,6 +675,9 @@ static struct bt_bap *bap_get_session(struct bt_att *att, struct gatt_db *db)
 	}
 
 	bap = bt_bap_new(db, NULL);
+	if (!bap)
+		return NULL;
+
 	bap->att = att;
 
 	bt_bap_attach(bap, NULL);
@@ -845,7 +848,7 @@ static void ascs_ase_read(struct gatt_db_attribute *attrib,
 	struct bt_ascs_ase_status rsp;
 
 	if (ase)
-		bap = bap_get_session(att, ase->ascs->bdb->db);
+		bap = bt_bap_get_session(att, ase->ascs->bdb->db);
 
 	if (bap)
 		ep = bap_get_endpoint(bap->local_eps, bap->ldb, attrib);
@@ -3437,7 +3440,7 @@ static void ascs_ase_cp_write(struct gatt_db_attribute *attrib,
 				void *user_data)
 {
 	struct bt_ascs *ascs = user_data;
-	struct bt_bap *bap = bap_get_session(att, ascs->bdb->db);
+	struct bt_bap *bap = bt_bap_get_session(att, ascs->bdb->db);
 	struct iovec iov = {
 		.iov_base = (void *) value,
 		.iov_len = len,
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 359147b69..198ae50c5 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -296,3 +296,5 @@ unsigned int bt_bap_bcode_cb_register(struct bt_bap *bap,
 				bt_bap_destroy_func_t destroy);
 
 bool bt_bap_bcode_cb_unregister(struct bt_bap *bap, unsigned int id);
+
+struct bt_bap *bt_bap_get_session(struct bt_att *att, struct gatt_db *db);
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux