hid_host: emit HID_SUBEVENT_INCOMING_CONNECTION if memory allocation fails

This commit is contained in:
Matthias Ringwald 2025-02-24 11:01:31 +01:00
parent b848f4ec55
commit 9a2cabcf31
2 changed files with 13 additions and 13 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- HCI: hci_request_cis_can_send_now_events for CIG in Central role will emit can send now events for all streams in group
- GAP: validate params in gap_set_scan_params
- HID Host: emit HID_SUBEVENT_INCOMING_CONNECTION if memory allocation fails
- BTstack HID: remove HID_PROTOCOL_MODE_REPORT_WITH_FALLBACK_TO_BOOT
## Release v1.6.2

View File

@ -882,23 +882,22 @@ static void hid_host_packet_handler(uint8_t packet_type, uint16_t channel, uint8
l2cap_decline_connection(channel);
break;
}
connection = hid_host_create_connection(address);
if (!connection){
if (connection == NULL) {
log_error("Cannot create connection for %s", bd_addr_to_str(address));
l2cap_decline_connection(channel);
break;
// inform user about failed incoming connection due to memory
hid_emit_incoming_connection_event(connection->hid_cid, address, con_handle, ERROR_CODE_MEMORY_CAPACITY_EXCEEDED);
} else {
connection->state = HID_HOST_W4_CONTROL_CONNECTION_ESTABLISHED;
connection->hid_descriptor_status = ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
connection->con_handle = con_handle;
connection->control_cid = l2cap_event_incoming_connection_get_local_cid(packet);
connection->incoming = true;
// emit connection request
// user calls either hid_host_accept_connection or hid_host_decline_connection
hid_emit_incoming_connection_event(connection->hid_cid, address, con_handle, ERROR_CODE_SUCCESS);
}
connection->state = HID_HOST_W4_CONTROL_CONNECTION_ESTABLISHED;
connection->hid_descriptor_status = ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
connection->con_handle = con_handle;
connection->control_cid = l2cap_event_incoming_connection_get_local_cid(packet);
connection->incoming = true;
// emit connection request
// user calls either hid_host_accept_connection or hid_host_decline_connection
hid_emit_incoming_connection_event(connection->hid_cid, address, con_handle, ERROR_CODE_SUCCESS);
break;
case PSM_HID_INTERRUPT: