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 <gabriel.ganne@gmail.com>
Change-Id: I2f894176d39b3d15efab054dc7340e7a0600a2e8
This commit is contained in:
Gabriel Ganne
2022-05-05 10:16:56 +02:00
committed by Damjan Marion
parent da052b62bd
commit 01f6c73530

View 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;
}