gnrc_sixlowpan_frag_rb: fix memory-leak in _rm_by_datagram()#12845
Merged
miri64 merged 2 commits intoRIOT-OS:masterfrom Dec 2, 2019
Merged
Conversation
gnrc_sixlowpan_frag_rm_by_datagram() currently doesn't release the packet in the reassembly buffer entry removed, meaning it puts a leak into the packet buffer. This changes the tests to check for that error.
This fits with the semantics of this function which doesn't provide or uses any state of the reassembly buffer provided by the user, but finds the entry itself and then removes it. This gives the user no chance to remove the packet in the reassembly buffer entry, so `gnrc_sixlowpan_frag_rb_rm_by_datagram()` has to release the packet (other than `gnrc_sixlowpan_frag_rb_remove()` where not releasing the packet is desired as it might be handed up to an upper layer).
benpicco
approved these changes
Dec 2, 2019
Contributor
benpicco
left a comment
There was a problem hiding this comment.
The reasoning provided is sound and there is a test case to keep track of this in the future.
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.
Contribution description
This adds a
gnrc_pktbuf_release()to the functiongnrc_sixlowpan_frag_rm_by_datagram().This fits with the semantics of this function which doesn't provide or uses any state of the reassembly buffer provided by the user, but finds the entry itself and then removes it. This gives the user no chance to remove the packet in the reassembly buffer entry, so
gnrc_sixlowpan_frag_rb_rm_by_datagram()has to release the packet (other thangnrc_sixlowpan_frag_rb_remove()where not releasing the packet is desired as it might be handed up to an upper layer).Testing procedure
I adapted the tests for the reassembly buffer to check this error:
Without the fix (
git reset --hard HEAD~1) it fails, with it it succeeds.Issues/PRs references
Follow-up on/Bug fix for a feature introduced in #12349