[riot-notifications] [RIOT-OS/RIOT] gnrc: packet space in gnrc packet buffer is not released on very heavy load (#10701)

Gunar Schorcht notifications at github.com
Fri Jan 4 01:57:33 CET 2019

@miri64 Might this https://github.com/RIOT-OS/RIOT/blob/b77c802f9b68d9272da21386a4d0ccee4677ac59/sys/shell/commands/sc_icmpv6_echo.c#L248-L253 and https://github.com/RIOT-OS/RIOT/blob/b77c802f9b68d9272da21386a4d0ccee4677ac59/sys/shell/commands/sc_icmpv6_echo.c#L256-L262 be potential leaks?

I went through `pktbuf` code and if I didn't miss something the `gnrc_pktbuf_release(pkt)` releases `pkt` including all `pkt->next` snips, but `gnrc_pktbuf_add` doesn't release `next` snip(s) if the new buffer space couldn't be allocated. So I would guess that the packet allocated before and used as parameter `pkt` is not freed in the code above, if the new packet snip could not be allocated.

If I'm correct, the code probably looks like the following:
+       gnrc_pktsnip_t *next = pkt;
-       pkt = gnrc_ipv6_hdr_build(pkt, NULL, &addr);
+       pkt = gnrc_ipv6_hdr_build(next, NULL, &addr);

        if (pkt == NULL) {
+           gnrc_pktbuf_release(next);
            puts("error: packet buffer full");
+           next = pkt;
-           pkt = gnrc_pktbuf_add(pkt, NULL, sizeof(gnrc_netif_hdr_t), GNRC_NETTYPE_NETIF);
+           pkt = gnrc_pktbuf_add(next, NULL, sizeof(gnrc_netif_hdr_t), GNRC_NETTYPE_NETIF);

            if (pkt == NULL) {
+               gnrc_pktbuf_release(next);
                puts("error: packet buffer full");

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190103/eab286b2/attachment.html>

More information about the notifications mailing list