Fix/uart init error path deinit - #655
Merged
Merged
Conversation
tkl_ble_gatts_service_add() returned early on invalid parameters and allocation failures without releasing the service/characteristic UUIDs already allocated in the same call, and never checked the results of tal_malloc()/tuya_ble_hs_malloc(). - extract tuya_ble_gatts_uuid_free() and share it between the stack deinit path and the new exit_cleanup path - check every allocation and reject unknown UUID types explicitly - clear tuya_gatt_svcs / read_char buffer pointers after freeing so a second deinit cannot double free - bound char_num per service instead of accumulating across services, which could overflow a tuya_gatt_chars row
Once tkl_uart_init() succeeded, every later failure in tal_uart_init() jumped to ERR_EXIT, and uart_free_source() only releases TAL level objects. The lower layer stayed initialized: on the Linux adapter that leaks a file descriptor and the IRQ thread started by tkl_uart_init(). - track whether tkl_uart_init() succeeded and call tkl_uart_deinit() from ERR_EXIT before uart_free_source() - handle uart_list_add_one_node() failure, which previously returned an error while leaving the port initialized and the node off the list, where tal_uart_deinit() could never reclaim it - tal_cli_init_with_uart(): call tal_uart_deinit() when the CLI thread cannot be created after the UART came up, and add the missing format specifier to the uart init failure log Fixes #632
This was referenced Jul 28, 2026
yingtao450
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 描述/PR description
[在此详细描述 PR 的内容]/[Describe the PR content in detail here]
代码质量/Code Quality:
在本次拉取请求中,我已考虑以下事项 As part of this pull request, I've considered the following: