From 01f6c7353084d1180387ae64b936e96028e17fbd Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Thu, 5 May 2022 10:16:56 +0200 Subject: 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 --- src/vnet/devices/af_packet/af_packet.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/vnet/devices/af_packet') 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; } -- cgit 1.2.3-korg