]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_conn: Reduce hci_conn_drop() calls in two functions
authorMarkus Elfring <elfring@users.sourceforge.net>
Tue, 1 Oct 2024 07:21:25 +0000 (09:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:55 +0000 (20:03 +0100)
[ Upstream commit d96b543c6f3b78b6440b68b5a5bbface553eff28 ]

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 <elfring@users.sourceforge.net>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/hci_conn.c

index 6354cdf9c2b3725769ee255bef41f7373b12434b..a1dfd865d61ab87bc8ebd944b42c530cd8c21f21 100644 (file)
@@ -2345,13 +2345,9 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst,
                                          conn->iso_qos.bcast.big);
        if (parent && parent != conn) {
                link = hci_conn_link(parent, conn);
-               if (!link) {
-                       hci_conn_drop(conn);
-                       return ERR_PTR(-ENOLINK);
-               }
-
-               /* Link takes the refcount */
                hci_conn_drop(conn);
+               if (!link)
+                       return ERR_PTR(-ENOLINK);
        }
 
        return conn;
@@ -2441,15 +2437,12 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
        }
 
        link = hci_conn_link(le, cis);
+       hci_conn_drop(cis);
        if (!link) {
                hci_conn_drop(le);
-               hci_conn_drop(cis);
                return ERR_PTR(-ENOLINK);
        }
 
-       /* Link takes the refcount */
-       hci_conn_drop(cis);
-
        cis->state = BT_CONNECT;
 
        hci_le_create_cis_pending(hdev);