Skip to content

Commit aca3772

Browse files
pvVudentz
authored andcommitted
Bluetooth: hci_sync: fix leaks when hci_cmd_sync_queue_once fails
When hci_cmd_sync_queue_once() returns with error, the destroy callback will not be called. Fix leaking references / memory on these failures. Signed-off-by: Pauli Virtanen <pav@iki.fi> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 2969554 commit aca3772

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

net/bluetooth/hci_sync.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7460,13 +7460,16 @@ int hci_le_read_remote_features(struct hci_conn *conn)
74607460
* role is possible. Otherwise just transition into the
74617461
* connected state without requesting the remote features.
74627462
*/
7463-
if (conn->out || (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES))
7463+
if (conn->out || (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) {
74647464
err = hci_cmd_sync_queue_once(hdev,
74657465
hci_le_read_remote_features_sync,
74667466
hci_conn_hold(conn),
74677467
le_read_features_complete);
7468-
else
7468+
if (err)
7469+
hci_conn_drop(conn);
7470+
} else {
74697471
err = -EOPNOTSUPP;
7472+
}
74707473

74717474
return (err == -EEXIST) ? 0 : err;
74727475
}
@@ -7505,6 +7508,9 @@ int hci_acl_change_pkt_type(struct hci_conn *conn, u16 pkt_type)
75057508

75067509
err = hci_cmd_sync_queue_once(hdev, hci_change_conn_ptype_sync, cp,
75077510
pkt_type_changed);
7511+
if (err)
7512+
kfree(cp);
7513+
75087514
return (err == -EEXIST) ? 0 : err;
75097515
}
75107516

@@ -7544,5 +7550,8 @@ int hci_le_set_phy(struct hci_conn *conn, u8 tx_phys, u8 rx_phys)
75447550

75457551
err = hci_cmd_sync_queue_once(hdev, hci_le_set_phy_sync, cp,
75467552
le_phy_update_complete);
7553+
if (err)
7554+
kfree(cp);
7555+
75477556
return (err == -EEXIST) ? 0 : err;
75487557
}

0 commit comments

Comments
 (0)