From: Ismagil Iskakov <i.iskakov@omp.ru>
To: <linux-bluetooth@vger.kernel.org>
Cc: Ismagil Iskakov <i.iskakov@omp.ru>
Subject: [PATCH BlueZ 06/11] profiles/audio: fix memleak of bt_bap
Date: Tue, 8 Jul 2025 10:33:29 +0300 [thread overview]
Message-ID: <20250708073334.2393559-7-i.iskakov@omp.ru> (raw)
In-Reply-To: <20250708073334.2393559-1-i.iskakov@omp.ru>
Make failure branches deallocate memory before leaving.
---
profiles/audio/bap.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index ee7c8bc49..11e7b1546 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -2954,31 +2954,32 @@ static int bap_bcast_probe(struct btd_service *service)
struct btd_adapter *adapter = device_get_adapter(device);
struct btd_gatt_database *database = btd_adapter_get_database(adapter);
struct bap_data *data;
+ struct bt_bap *bap;
if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) {
error("BAP requires ISO Socket which is not enabled");
return -ENOTSUP;
}
- data = bap_data_new(device);
- data->service = service;
- data->adapter = adapter;
- data->device = device;
- data->bap = bt_bap_new(btd_gatt_database_get_db(database),
+ bap = bt_bap_new(btd_gatt_database_get_db(database),
btd_gatt_database_get_db(database));
- if (!data->bap) {
+ if (!bap) {
error("Unable to create BAP instance");
- free(data);
return -EINVAL;
}
- data->bcast_snks = queue_new();
+ bt_bap_set_user_data(bap, service);
- bt_bap_set_user_data(data->bap, service);
-
- if (!bt_bap_attach(data->bap, NULL)) {
+ if (!bt_bap_attach(bap, NULL)) {
error("BAP unable to attach");
+ bt_bap_unref(bap);
return -EINVAL;
}
+ data = bap_data_new(device);
+ data->service = service;
+ data->adapter = adapter;
+ data->device = device;
+ data->bap = bap;
+ data->bcast_snks = queue_new();
bap_data_add(data);
--
2.34.1
next prev parent reply other threads:[~2025-07-08 7:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 7:33 [PATCH BlueZ 00/11] Fix bugs found by static analysis Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 01/11] btio: fix range validation of security level Ismagil Iskakov
2025-07-08 7:51 ` Fix bugs found by static analysis bluez.test.bot
2025-07-08 7:33 ` [PATCH BlueZ 02/11] profiles/audio: add nullity checks Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 03/11] src/shared: " Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 04/11] isotest: close fd after sending when nconn=1 Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 05/11] obexd/client: fix err condition causing memleak Ismagil Iskakov
2025-07-08 7:33 ` Ismagil Iskakov [this message]
2025-07-08 7:33 ` [PATCH BlueZ 07/11] src/shared: fix memleak Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 08/11] src/shared: move null checks before dereferencing Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 09/11] isotest: remove repeating conditions Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 10/11] profiles/audio: fix io_unlink args order Ismagil Iskakov
2025-07-08 7:33 ` [PATCH BlueZ 11/11] src/plugin: fix " Ismagil Iskakov
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=20250708073334.2393559-7-i.iskakov@omp.ru \
--to=i.iskakov@omp.ru \
--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