From fc000a6d8118965ac372eed8eface9cbc721335a Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 25 Apr 2023 07:22:15 +0200 Subject: [PATCH] af/xdp: fix memory leaks on thread init failure source-af-xdp.c:675:21: warning: Potential leak of memory pointed to by 'ptv' [unix.Malloc] SCReturnInt(TM_ECODE_FAILED); ^~~~~~~~~~~~~~~ ./util-debug.h:275:48: note: expanded from macro 'SCReturnInt' #define SCReturnInt(x) return x ^ 1 warning generated. --- src/source-af-xdp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/source-af-xdp.c b/src/source-af-xdp.c index 4036e05076..6f8f8815e0 100644 --- a/src/source-af-xdp.c +++ b/src/source-af-xdp.c @@ -628,6 +628,7 @@ static TmEcode ReceiveAFXDPThreadInit(ThreadVars *tv, const void *initdata, void if (SetIfaceFlags(ptv->iface, IFF_PROMISC | IFF_UP) != 0) { SCLogError("Failed to switch interface (%s) to promiscuous, error %s", ptv->iface, strerror(errno)); + SCFree(ptv); SCReturnInt(TM_ECODE_FAILED); } } @@ -672,10 +673,12 @@ static TmEcode ReceiveAFXDPThreadInit(ThreadVars *tv, const void *initdata, void /* Reserve memory for umem */ if (AcquireBuffer(ptv) != TM_ECODE_OK) { + SCFree(ptv); SCReturnInt(TM_ECODE_FAILED); } if (AFXDPSocketCreation(ptv) != TM_ECODE_OK) { + ReceiveAFXDPThreadDeinit(tv, ptv); SCReturnInt(TM_ECODE_FAILED); } -- 2.47.2