Skip to content

gnrc_sixlowpan_frag_rb: fix memory-leak in _rm_by_datagram()#12845

Merged
miri64 merged 2 commits intoRIOT-OS:masterfrom
miri64:gnrc_sixlowpan_frag_rb/fix/rm-by-datagram-pkt-release
Dec 2, 2019
Merged

gnrc_sixlowpan_frag_rb: fix memory-leak in _rm_by_datagram()#12845
miri64 merged 2 commits intoRIOT-OS:masterfrom
miri64:gnrc_sixlowpan_frag_rb/fix/rm-by-datagram-pkt-release

Conversation

@miri64
Copy link
Copy Markdown
Member

@miri64 miri64 commented Nov 29, 2019

Contribution description

This adds a gnrc_pktbuf_release() to the function gnrc_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 than gnrc_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:

make -C tests/gnrc_sixlowpan_frag flash test

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

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).
@miri64 miri64 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking labels Nov 29, 2019
@miri64 miri64 requested review from benpicco and cgundogan November 29, 2019 14:45
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 29, 2019
Copy link
Copy Markdown
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

The reasoning provided is sound and there is a test case to keep track of this in the future.

@miri64 miri64 merged commit 09c46e2 into RIOT-OS:master Dec 2, 2019
@miri64 miri64 deleted the gnrc_sixlowpan_frag_rb/fix/rm-by-datagram-pkt-release branch December 2, 2019 18:21
@fjmolinas fjmolinas added this to the Release 2020.01 milestone Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants