tests: bluetooth: tester: Fix NULL pointer dereference in error path

bt_conn_unref() requires valid conn pointer but could be called with
NULL in case valid connection was not found in disconnect_eatt_chans().

Fixes #39851

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This commit is contained in:
Szymon Janc 2021-10-28 16:05:54 +02:00 committed by Anas Nashif
parent 33380d7cc6
commit d0b02cde2c

View File

@ -342,22 +342,22 @@ void disconnect_eatt_chans(uint8_t *data, uint16_t len)
if (!conn) {
LOG_ERR("Unknown connection");
status = BTP_STATUS_FAILED;
goto rsp;
goto failed;
}
for (int i = 0; i < cmd->count; i++) {
err = bt_eatt_disconnect_one(conn);
if (err) {
status = BTP_STATUS_FAILED;
goto rsp;
goto unref;
}
}
status = BTP_STATUS_SUCCESS;
rsp:
unref:
bt_conn_unref(conn);
failed:
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_DISCONNECT_EATT_CHANS,
CONTROLLER_INDEX, status);
}