From: Gabriel Ganne Date: Thu, 5 May 2022 08:16:56 +0000 (+0200) Subject: devices: fix crash on invalid interface X-Git-Tag: v22.10-rc0~42 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F36084%2F3;p=vpp.git devices: fix crash on invalid interface Type: fix A simple "create host-interface name xxx" is enough to trigger the bug: The interface is not found, and we goto error with apif=NULL Signed-off-by: Gabriel Ganne Change-Id: I2f894176d39b3d15efab054dc7340e7a0600a2e8 --- diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c index 10b0ff2fb1a..83c10684c9f 100644 --- a/src/vnet/devices/af_packet/af_packet.c +++ b/src/vnet/devices/af_packet/af_packet.c @@ -679,8 +679,11 @@ error: fd2 = -1; } vec_free (host_if_name_dup); - memset (apif, 0, sizeof (*apif)); - pool_put (apm->interfaces, apif); + if (apif) + { + memset (apif, 0, sizeof (*apif)); + pool_put (apm->interfaces, apif); + } return ret; }