From d0d6b942e954b5e26d04ba830ec1fe5fa1f4d4b6 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 15 Apr 2019 08:48:10 +0000 Subject: crypto: fix coverity warnings Change-Id: Id9dfd912517c44cf812953bd05ac04c9e172a2b7 Signed-off-by: Filip Tehlar --- src/plugins/crypto_ipsecmb/ipsecmb.c | 2 ++ src/plugins/unittest/crypto_test.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/crypto_ipsecmb/ipsecmb.c b/src/plugins/crypto_ipsecmb/ipsecmb.c index 8e40e3ec2e9..d579c0d74a6 100644 --- a/src/plugins/crypto_ipsecmb/ipsecmb.c +++ b/src/plugins/crypto_ipsecmb/ipsecmb.c @@ -321,10 +321,12 @@ crypto_ipsecmb_iv_init (ipsecmb_main_t * imbm) if (read (fd, &ptd->cbc_iv, sizeof (ptd->cbc_iv)) != sizeof (ptd->cbc_iv)) { err = clib_error_return_unix (0, "'/dev/urandom' read failure"); + close (fd); return (err); } } + close (fd); return (NULL); } diff --git a/src/plugins/unittest/crypto_test.c b/src/plugins/unittest/crypto_test.c index fba1e0696aa..37cdc688f5e 100644 --- a/src/plugins/unittest/crypto_test.c +++ b/src/plugins/unittest/crypto_test.c @@ -81,6 +81,10 @@ test_crypto (vlib_main_t * vm, crypto_test_main_t * tm) r = r->next; } + /* no tests registered */ + if (n_ops == 0) + return 0; + vec_sort_with_function (rv, sort_registrations); vec_validate_aligned (computed_data, computed_data_total_len - 1, @@ -158,8 +162,6 @@ test_crypto (vlib_main_t * vm, crypto_test_main_t * tm) op->user_data = i; op++; } - /* next */ - r = r->next; } /* *INDENT-ON* */ @@ -177,6 +179,7 @@ test_crypto (vlib_main_t * vm, crypto_test_main_t * tm) { case VNET_CRYPTO_OP_TYPE_AEAD_ENCRYPT: exp_tag = &r->tag; + /* fall through */ case VNET_CRYPTO_OP_TYPE_ENCRYPT: exp_ct = &r->ciphertext; break; -- cgit 1.2.3-korg