andrzej-kaczmarek commented on issue #1590:
URL: https://github.com/apache/mynewt-nimble/issues/1590#issuecomment-1674388846
Hi Peter,
On Fri, 11 Aug 2023 at 09:37, Peter ***@***.***> wrote:
> Hello,
>
> I am using an STM32 (with FreeRTOS) connected through uart to an NXP
> 88w8987. While working on getting nimble to work I noticed that HCI
> commands sent from host to controller with ble_hs_hci_cmd_send are not
> freed. There is a buffer of size 1 (i.e. 1 command) so I got a crash on the
> second command due to failed memory allocation.
>
Commands are freed by transport, the host does not need to do this. I
assume you use uart_ll transport since you have external controller so in
this case it happens in hci_uart_tx_char @
nimble/transport/uart_ll/src/hci_uart.c when last byte from command buffer
was consumed. If it does not work for you, I'd suggest debugging that
function to see what happens. I don't see anything wrong with that function
at first glance.
> I have modified nimble/host/src/ble_hs_hci_cmd.c like this:
> ble_hs_hci_cmd_send(uint16_t opcode, uint8_t len, const void *cmddata)
> {
> ....
> ble_transport_free_cmd(cmd);
> return rc;
> }
>
> and added the free-function to nimble/transport/src/transport.c:
> os_error_t ble_transport_free_cmd(void * cmd) {
> return os_memblock_put(&pool_cmd, cmd);
> }
>
> and now it works for me. Is the free-ing missing or am I missing something?
>
This won't work properly with RAM transport since command buffers are
passed directly to LL so there will be use-after-free error.
BR,
Andrzej
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/mynewt-nimble/issues/1590>, or unsubscribe
>
<https://github.com/notifications/unsubscribe-auth/ACJ6MDL24T6JOIPSTPMFZHLXUXOKFANCNFSM6AAAAAA3MRF7H4>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]