Skip to content

Commit 2438301

Browse files
sjancrlubos
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit ef0e75134ef6463025256f0904c1957b72c10693) Signed-off-by: Robert Lubos <[email protected]>
1 parent 3c79b20 commit 2438301

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/bluetooth/tester/src/l2cap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,22 +344,22 @@ void disconnect_eatt_chans(uint8_t *data, uint16_t len)
344344
if (!conn) {
345345
LOG_ERR("Unknown connection");
346346
status = BTP_STATUS_FAILED;
347-
goto rsp;
347+
goto failed;
348348
}
349349

350350
for (int i = 0; i < cmd->count; i++) {
351351
err = bt_eatt_disconnect_one(conn);
352352
if (err) {
353353
status = BTP_STATUS_FAILED;
354-
goto rsp;
354+
goto unref;
355355
}
356356
}
357357

358358
status = BTP_STATUS_SUCCESS;
359359

360-
rsp:
360+
unref:
361361
bt_conn_unref(conn);
362-
362+
failed:
363363
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_DISCONNECT_EATT_CHANS,
364364
CONTROLLER_INDEX, status);
365365
}

0 commit comments

Comments
 (0)