* [PATCH] Bluetooth: hci_conn: fix memory leak in hci_le_terminate_big() and hci_le_big_terminate()
@ 2023-01-04 6:46 Zhengchao Shao
2023-01-05 23:50 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 2+ messages in thread
From: Zhengchao Shao @ 2023-01-04 6:46 UTC (permalink / raw)
To: linux-bluetooth, netdev, marcel, johan.hedberg, luiz.dentz, davem,
edumazet, kuba, pabeni
Cc: weiyongjun1, yuehaibing, shaozhengchao
When hci_cmd_sync_queue() failed in hci_le_terminate_big() or
hci_le_big_terminate(), the memory pointed by variable d is not freed,
which will cause memory leak. Add release process to error path.
Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
net/bluetooth/hci_conn.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index d3e542c2fc3e..acf563fbdfd9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -821,6 +821,7 @@ static void terminate_big_destroy(struct hci_dev *hdev, void *data, int err)
static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis)
{
struct iso_list_data *d;
+ int ret;
bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis);
@@ -831,8 +832,12 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis)
d->big = big;
d->bis = bis;
- return hci_cmd_sync_queue(hdev, terminate_big_sync, d,
- terminate_big_destroy);
+ ret = hci_cmd_sync_queue(hdev, terminate_big_sync, d,
+ terminate_big_destroy);
+ if (ret)
+ kfree(d);
+
+ return ret;
}
static int big_terminate_sync(struct hci_dev *hdev, void *data)
@@ -857,6 +862,7 @@ static int big_terminate_sync(struct hci_dev *hdev, void *data)
static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle)
{
struct iso_list_data *d;
+ int ret;
bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle);
@@ -867,8 +873,12 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle)
d->big = big;
d->sync_handle = sync_handle;
- return hci_cmd_sync_queue(hdev, big_terminate_sync, d,
- terminate_big_destroy);
+ ret = hci_cmd_sync_queue(hdev, big_terminate_sync, d,
+ terminate_big_destroy);
+ if (ret)
+ kfree(d);
+
+ return ret;
}
/* Cleanup BIS connection
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Bluetooth: hci_conn: fix memory leak in hci_le_terminate_big() and hci_le_big_terminate()
2023-01-04 6:46 [PATCH] Bluetooth: hci_conn: fix memory leak in hci_le_terminate_big() and hci_le_big_terminate() Zhengchao Shao
@ 2023-01-05 23:50 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2023-01-05 23:50 UTC (permalink / raw)
To: Zhengchao Shao
Cc: linux-bluetooth, netdev, marcel, johan.hedberg, luiz.dentz, davem,
edumazet, kuba, pabeni, weiyongjun1, yuehaibing
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 4 Jan 2023 14:46:23 +0800 you wrote:
> When hci_cmd_sync_queue() failed in hci_le_terminate_big() or
> hci_le_big_terminate(), the memory pointed by variable d is not freed,
> which will cause memory leak. Add release process to error path.
>
> Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>
> [...]
Here is the summary with links:
- Bluetooth: hci_conn: fix memory leak in hci_le_terminate_big() and hci_le_big_terminate()
https://git.kernel.org/bluetooth/bluetooth-next/c/5d043a6a43b6
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] 2+ messages in thread
end of thread, other threads:[~2023-01-05 23:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 6:46 [PATCH] Bluetooth: hci_conn: fix memory leak in hci_le_terminate_big() and hci_le_big_terminate() Zhengchao Shao
2023-01-05 23:50 ` patchwork-bot+bluetooth
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).