Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: net: buf: Fix cloning of zero-sized buffers #70585

Conversation

rettichschnidi
Copy link
Contributor

@rettichschnidi rettichschnidi commented Mar 22, 2024

For zero sized buffers, instead of pointing to a buffer, net_buf->__buf
is NULL. For this reason, when cloning a buffer, the code needs to check
__buf before dereferencing it.

@rettichschnidi rettichschnidi marked this pull request as ready for review March 22, 2024 21:31
@zephyrbot zephyrbot added area: Networking area: Networking Buffers net_buf/net_buf_simple API & implementation labels Mar 22, 2024
@rettichschnidi rettichschnidi force-pushed the gardena/rs/upstream/net-buf-fix-clone-reference-counted-zero-sized-buffer branch from c0a5ab0 to f086d59 Compare March 22, 2024 21:33
@rettichschnidi rettichschnidi marked this pull request as draft March 22, 2024 21:33
@rettichschnidi rettichschnidi marked this pull request as ready for review March 22, 2024 21:48
jukkar
jukkar previously approved these changes Mar 23, 2024
@rettichschnidi rettichschnidi force-pushed the gardena/rs/upstream/net-buf-fix-clone-reference-counted-zero-sized-buffer branch from f086d59 to 88e7e49 Compare March 24, 2024 15:18
@rettichschnidi
Copy link
Contributor Author

Rebased because of a conflict.

@rettichschnidi rettichschnidi requested a review from jukkar March 24, 2024 15:19
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

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

Nit: split into 2 commits?

@rettichschnidi rettichschnidi force-pushed the gardena/rs/upstream/net-buf-fix-clone-reference-counted-zero-sized-buffer branch from 88e7e49 to 289d49d Compare March 25, 2024 14:36
@rettichschnidi
Copy link
Contributor Author

Nit: split into 2 commits?

Done

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 25, 2024

Nit: split into 2 commits?

Done

The first commit subject shouldn't start with tests: .

For zero sized buffers, instead of pointing to a buffer, net_buf->__buf
is NULL. For this reason, when cloning a buffer, the code needs to check
__buf before dereferencing it.

Signed-off-by: Reto Schneider <[email protected]>
This commit ensures that copying a zero-sized buffer works.

Signed-off-by: Reto Schneider <[email protected]>
@rettichschnidi rettichschnidi force-pushed the gardena/rs/upstream/net-buf-fix-clone-reference-counted-zero-sized-buffer branch from 289d49d to dbbd9fc Compare March 25, 2024 22:41
@nashif nashif merged commit a924c87 into zephyrproject-rtos:main Mar 26, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking Buffers net_buf/net_buf_simple API & implementation area: Networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants