Move conn pointer dereference before the done label, because it is a goto label in case of error handling - when the conn is NULL. --- emulator/btdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 3840c6150..c76b89db9 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -1327,6 +1327,8 @@ static int cmd_add_sco_conn(struct btdev *dev, const void *data, uint8_t len) goto done; } + pending_conn_del(dev, conn->link->dev); + cc.status = BT_HCI_ERR_SUCCESS; memcpy(cc.bdaddr, conn->link->dev->bdaddr, 6); cc.handle = cpu_to_le16(conn->handle); @@ -1334,8 +1336,6 @@ static int cmd_add_sco_conn(struct btdev *dev, const void *data, uint8_t len) cc.encr_mode = 0x00; done: - pending_conn_del(dev, conn->link->dev); - send_event(dev, BT_HCI_EVT_CONN_COMPLETE, &cc, sizeof(cc)); return 0; -- 2.39.2