Commit d96b543c authored by Markus Elfring's avatar Markus Elfring Committed by Luiz Augusto von Dentz
Browse files

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 8c52d2f8
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -2224,15 +2224,11 @@ 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);
		if (!link)
			return ERR_PTR(-ENOLINK);
	}

		/* Link takes the refcount */
		hci_conn_drop(conn);
	}

	return conn;
}

@@ -2320,15 +2316,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);