Skip to content

Commit d0b02cd

Browse files
sjancnashif
authored andcommitted
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]>
1 parent 33380d7 commit d0b02cd

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
@@ -342,22 +342,22 @@ void disconnect_eatt_chans(uint8_t *data, uint16_t len)
342342
if (!conn) {
343343
LOG_ERR("Unknown connection");
344344
status = BTP_STATUS_FAILED;
345-
goto rsp;
345+
goto failed;
346346
}
347347

348348
for (int i = 0; i < cmd->count; i++) {
349349
err = bt_eatt_disconnect_one(conn);
350350
if (err) {
351351
status = BTP_STATUS_FAILED;
352-
goto rsp;
352+
goto unref;
353353
}
354354
}
355355

356356
status = BTP_STATUS_SUCCESS;
357357

358-
rsp:
358+
unref:
359359
bt_conn_unref(conn);
360-
360+
failed:
361361
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_DISCONNECT_EATT_CHANS,
362362
CONTROLLER_INDEX, status);
363363
}

0 commit comments

Comments
 (0)