From: Victor Julien Date: Wed, 23 Feb 2022 12:40:59 +0000 (+0100) Subject: decode: release refs from PacketFree X-Git-Tag: suricata-5.0.9~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=593ba75b2d4142cb850aa31747199a80a8fa8703;p=thirdparty%2Fsuricata.git decode: release refs from PacketFree Mostly helps unittests. (cherry picked from commit f07d5b2d89ed27d075e9f9328fd678d6ea701889) --- diff --git a/src/decode.h b/src/decode.h index ddb4a105f2..825bd9cfae 100644 --- a/src/decode.h +++ b/src/decode.h @@ -827,17 +827,18 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s); /** * \brief Cleanup a packet so that we can free it. No memset needed.. */ -#define PACKET_DESTRUCTOR(p) do { \ - if ((p)->pktvar != NULL) { \ - PktVarFree((p)->pktvar); \ - } \ - PACKET_FREE_EXTDATA((p)); \ - SCMutexDestroy(&(p)->tunnel_mutex); \ - AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \ - PACKET_PROFILING_RESET((p)); \ +#define PACKET_DESTRUCTOR(p) \ + do { \ + PACKET_RELEASE_REFS((p)); \ + if ((p)->pktvar != NULL) { \ + PktVarFree((p)->pktvar); \ + } \ + PACKET_FREE_EXTDATA((p)); \ + SCMutexDestroy(&(p)->tunnel_mutex); \ + AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \ + PACKET_PROFILING_RESET((p)); \ } while (0) - /* macro's for setting the action * handle the case of a root packet * for tunnels */ diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index cea1212197..9a5fdaa47e 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -289,14 +289,14 @@ Packet *PacketPoolGetPacket(void) void PacketPoolReturnPacket(Packet *p) { PktPool *my_pool = GetThreadPacketPool(); - - PACKET_RELEASE_REFS(p); - PktPool *pool = p->pool; if (pool == NULL) { PacketFree(p); return; } + + PACKET_RELEASE_REFS(p); + #ifdef DEBUG_VALIDATION BUG_ON(pool->initialized == 0); BUG_ON(pool->destroyed == 1);