charon-tkm: Check for error when acquiring ESA ID

This commit is contained in:
Adrian-Ken Rueegsegger
2017-09-15 12:16:57 +02:00
committed by Tobias Brunner
parent 8e823bb8b1
commit 59e7298ff9
@@ -134,6 +134,12 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
}
esa_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_ESA);
if (esa_id == 0)
{
DBG1(DBG_KNL, "unable to acquire esa context id");
goto esa_id_failure;
}
if (!tkm->sad->insert(tkm->sad, esa_id, data->reqid, local, peer,
spi_loc, spi_rem, id->proto))
{
@@ -196,6 +202,7 @@ failure:
tkm->sad->remove(tkm->sad, esa_id);
sad_failure:
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_ESA, esa_id);
esa_id_failure:
chunk_free(&esa.nonce_i);
chunk_free(&esa.nonce_r);
return FAILED;