Skip to content

Conversation

niedzwiecki-dawid
Copy link
Member

The PR fixes 2 bugs in the backend:

  • double-free of net buf
  • net_buf_reset called for net buffer with external memory

Using net_buf_reset for net buffers with external memory is not allowed.
Do not use it for tx_buf. Reset the buffer by restoring the default
buffer manually.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Fix double free of a net buffer after request error.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Copy link

sonarqubecloud bot commented Oct 1, 2025

k_work_schedule(&ctx->reset_work, K_MSEC(IN_TRANSFER_TIMEOUT_MS));

net_buf_reset(ctx->usb_tx_buf);
ctx->usb_tx_buf->data = ctx->tx_buf->buf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the issue, what is the problem with net_buf_reset?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

net_buf_reset doesn't accept buffers with external data flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants