Skip to content

Commit d96b543

Browse files
elfringVudentz
authored andcommitted
Bluetooth: hci_conn: Reduce hci_conn_drop() calls in two functions
An hci_conn_drop() call was immediately used after a null pointer check for an hci_conn_link() call in two function implementations. Thus call such a function only once instead directly before the checks. This issue was transformed by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 8c52d2f commit d96b543

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

net/bluetooth/hci_conn.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,13 +2224,9 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst,
22242224
conn->iso_qos.bcast.big);
22252225
if (parent && parent != conn) {
22262226
link = hci_conn_link(parent, conn);
2227-
if (!link) {
2228-
hci_conn_drop(conn);
2229-
return ERR_PTR(-ENOLINK);
2230-
}
2231-
2232-
/* Link takes the refcount */
22332227
hci_conn_drop(conn);
2228+
if (!link)
2229+
return ERR_PTR(-ENOLINK);
22342230
}
22352231

22362232
return conn;
@@ -2320,15 +2316,12 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
23202316
}
23212317

23222318
link = hci_conn_link(le, cis);
2319+
hci_conn_drop(cis);
23232320
if (!link) {
23242321
hci_conn_drop(le);
2325-
hci_conn_drop(cis);
23262322
return ERR_PTR(-ENOLINK);
23272323
}
23282324

2329-
/* Link takes the refcount */
2330-
hci_conn_drop(cis);
2331-
23322325
cis->state = BT_CONNECT;
23332326

23342327
hci_le_create_cis_pending(hdev);

0 commit comments

Comments
 (0)