From 794cbd641b14f20eef5d10562fd895574ea45b1d Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Mon, 3 Feb 2020 12:06:11 +0100 Subject: [PATCH] Bluetooth: host: Fix handling of scan start failed Handle scan start failed and release the connection object in this case. Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/conn.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index d9722855c73..561017775a9 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -2253,7 +2253,12 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer, if (!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size) { bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN); - bt_le_scan_update(true); + if (bt_le_scan_update(true)) { + bt_conn_set_state(conn, BT_CONN_DISCONNECTED); + bt_conn_unref(conn); + + return NULL; + } return conn; }