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.
pull/8762/head
Victor Julien 4 years ago
parent ea67a2edd2
commit fc000a6d81

@ -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);
}

Loading…
Cancel
Save