devices: fix crash on invalid interface 84/36084/3
authorGabriel Ganne <gabriel.ganne@gmail.com>
Thu, 5 May 2022 08:16:56 +0000 (10:16 +0200)
committerDamjan Marion <dmarion@me.com>
Sun, 8 May 2022 14:00:11 +0000 (14:00 +0000)
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 <gabriel.ganne@gmail.com>
Change-Id: I2f894176d39b3d15efab054dc7340e7a0600a2e8

src/vnet/devices/af_packet/af_packet.c

index 10b0ff2..83c1068 100644 (file)
@@ -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;
 }