Skip to content

Commit 3aa2131

Browse files
zhengchaoshaoVudentz
authored andcommitted
Bluetooth: hci_conn: Fix memory leaks
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: eca0ae4 ("Bluetooth: Add initial implementation of BIS connections") Signed-off-by: Zhengchao Shao <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 3a4d29b commit 3aa2131

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

net/bluetooth/hci_conn.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ static void terminate_big_destroy(struct hci_dev *hdev, void *data, int err)
821821
static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis)
822822
{
823823
struct iso_list_data *d;
824+
int ret;
824825

825826
bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis);
826827

@@ -831,8 +832,12 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis)
831832
d->big = big;
832833
d->bis = bis;
833834

834-
return hci_cmd_sync_queue(hdev, terminate_big_sync, d,
835-
terminate_big_destroy);
835+
ret = hci_cmd_sync_queue(hdev, terminate_big_sync, d,
836+
terminate_big_destroy);
837+
if (ret)
838+
kfree(d);
839+
840+
return ret;
836841
}
837842

838843
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)
857862
static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle)
858863
{
859864
struct iso_list_data *d;
865+
int ret;
860866

861867
bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle);
862868

@@ -867,8 +873,12 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle)
867873
d->big = big;
868874
d->sync_handle = sync_handle;
869875

870-
return hci_cmd_sync_queue(hdev, big_terminate_sync, d,
871-
terminate_big_destroy);
876+
ret = hci_cmd_sync_queue(hdev, big_terminate_sync, d,
877+
terminate_big_destroy);
878+
if (ret)
879+
kfree(d);
880+
881+
return ret;
872882
}
873883

874884
/* Cleanup BIS connection

0 commit comments

Comments
 (0)