Skip to content

Commit 10bd57c

Browse files
committed
bsdkm: fix exit error handling.
1 parent 66c2fb7 commit 10bd57c

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

bsdkm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ other loadable modules to link to wolfCrypt.
77
Supported features:
88
- wolfCrypt in kernel.
99
- FIPS-wolfcrypt.
10+
- crypto acceleration: AES-NI, AVX, etc.
1011

1112
Planned features:
12-
- crypto acceleration: AES-NI, AVX, etc.
1313
- kernel opencrypto driver registration.
1414
- full wolfSSL in kernel (kernel TLS).
1515

bsdkm/wolfkmod.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,27 +215,31 @@ static int wolfkmod_cleanup(void)
215215
if (error != 0) {
216216
printf("error: wolfCrypt_Cleanup failed: %s\n",
217217
wc_GetErrorString(error));
218-
return (ECANCELED);
218+
error = ECANCELED;
219+
goto wolfkmod_cleanup_out;
219220
}
220221
#else
221222
error = wolfSSL_Cleanup();
222223
if (error != WOLFSSL_SUCCESS) {
223224
printf("error: wolfSSL_Cleanup failed: %s\n",
224225
wc_GetErrorString(error));
225-
return (ECANCELED);
226+
error = ECANCELED;
227+
goto wolfkmod_cleanup_out;
226228
}
227229
#endif /* WOLFCRYPT_ONLY */
228230

229231
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
230232
printf("info: libwolfssl " LIBWOLFSSL_VERSION_STRING
231233
" cleanup complete.\n");
232234
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
235+
error = 0;
233236

237+
wolfkmod_cleanup_out:
234238
#if defined(WOLFSSL_AESNI) || defined(WOLFSSL_KERNEL_BENCHMARKS)
235239
wolfkmod_vecreg_exit();
236240
#endif /* WOLFSSL_AESNI || WOLFSSL_KERNEL_BENCHMARKS*/
237241

238-
return (0);
242+
return (error);
239243
}
240244

241245
#if !defined(BSDKM_CRYPTO_REGISTER)
@@ -554,9 +558,9 @@ static int wolfkdriv_probesession(device_t dev,
554558
return (error);
555559
}
556560

557-
static int wolfkdriv_newsession_cipher(device_t dev,
558-
wolfkdriv_session_t * session,
559-
const struct crypto_session_params *csp)
561+
static int wolfkdriv_newsession_aes(device_t dev,
562+
wolfkdriv_session_t * session,
563+
const struct crypto_session_params *csp)
560564
{
561565
int error = 0;
562566
int klen = csp->csp_cipher_klen; /* key len in bytes */
@@ -624,7 +628,7 @@ static int wolfkdriv_newsession(device_t dev, crypto_session_t cses,
624628
break;
625629
case CSP_MODE_CIPHER:
626630
case CSP_MODE_AEAD:
627-
error = wolfkdriv_newsession_cipher(dev, session, csp);
631+
error = wolfkdriv_newsession_aes(dev, session, csp);
628632
break;
629633
default:
630634
__assert_unreachable();
@@ -638,9 +642,6 @@ static int wolfkdriv_newsession(device_t dev, crypto_session_t cses,
638642
return (error);
639643
}
640644

641-
/*
642-
*
643-
*/
644645
static void
645646
wolfkdriv_freesession(device_t dev, crypto_session_t cses)
646647
{
@@ -659,9 +660,6 @@ wolfkdriv_freesession(device_t dev, crypto_session_t cses)
659660
return;
660661
}
661662

662-
/*
663-
*
664-
*/
665663
static int wolfkdriv_cbc_work(device_t dev, wolfkdriv_session_t * session,
666664
struct cryptop * crp,
667665
const struct crypto_session_params * csp)
@@ -812,9 +810,6 @@ static int wolfkdriv_cbc_work(device_t dev, wolfkdriv_session_t * session,
812810
return (error);
813811
}
814812

815-
/*
816-
* todo: skeleton implementation, finish.
817-
*/
818813
static int wolfkdriv_gcm_work(device_t dev, wolfkdriv_session_t * session,
819814
struct cryptop * crp,
820815
const struct crypto_session_params * csp)
@@ -1056,7 +1051,7 @@ static driver_t wolfkdriv_driver = {
10561051
.size = sizeof(struct wolfkdriv_softc),
10571052
};
10581053

1059-
/* note: on x86, software-only drivers usually attach to nexus bus. */
1054+
/* on x86, software-only drivers usually attach to nexus bus. */
10601055
DRIVER_MODULE(libwolfssl, nexus, wolfkdriv_driver, NULL, NULL);
10611056
#endif /* BSDKM_CRYPTO_REGISTER */
10621057

0 commit comments

Comments
 (0)