Merge pull request #10565 from philljj/bsdkm_misc_cleanup

bsdkm: misc cleanup.
This commit is contained in:
Daniel Pouzzner
2026-06-05 15:21:57 -05:00
committed by GitHub
3 changed files with 30 additions and 9 deletions
+19 -8
View File
@@ -491,6 +491,7 @@ static int wolfkdriv_attach(device_t dev)
attach_out:
if (error) {
device_printf(dev, "error: attach_out: %d\n", error);
wolfkdriv_unregister(softc);
(void)wolfkmod_cleanup();
}
@@ -503,16 +504,14 @@ static int wolfkdriv_detach(device_t dev)
struct wolfkdriv_softc * softc = NULL;
int ret = 0;
/* unregister wolfcrypt algs */
softc = device_get_softc(dev);
wolfkdriv_unregister(softc);
ret = wolfkmod_cleanup();
if (ret == 0) {
/* unregister wolfcrypt algs */
softc = device_get_softc(dev);
wolfkdriv_unregister(softc);
}
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
device_printf(dev, "info: exiting detach\n");
device_printf(dev, "info: exiting detach: %d\n", ret);
#else
(void)ret;
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
return (0);
@@ -802,6 +801,7 @@ static int wolfkdriv_cbc_work(device_t dev, wolfkdriv_session_t * session,
cbc_work_out:
/* cleanup. */
wc_ForceZero(&aes, sizeof(aes));
wc_ForceZero(iv, sizeof(iv));
wc_ForceZero(block, sizeof(block));
@@ -812,6 +812,11 @@ cbc_work_out:
error);
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
if (error < 0) {
/* convert wolfcrypt errors to EINVAL. */
error = EINVAL;
}
return (error);
}
@@ -979,6 +984,7 @@ static int wolfkdriv_gcm_work(device_t dev, wolfkdriv_session_t * session,
gcm_work_out:
/* cleanup. */
wc_ForceZero(&aes, sizeof(aes));
wc_ForceZero(iv, sizeof(iv));
wc_ForceZero(auth_tag, sizeof(auth_tag));
@@ -989,6 +995,11 @@ gcm_work_out:
error);
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
if (error < 0) {
/* convert wolfcrypt errors to EINVAL. */
error = EINVAL;
}
return (error);
}
+1 -1
View File
@@ -212,7 +212,7 @@ static int wolfkdriv_test_aes_gcm(device_t dev, int crid)
XMEMSET(resultT, 0, sizeof(resultT));
XMEMSET(resultC, 0, sizeof(resultC));
XMEMSET(resultC2, 0, sizeof(resultC));
XMEMSET(resultC2, 0, sizeof(resultC2));
XMEMCPY(resultC2, p, sizeof(p));
/* wolfcrypt encrypt */
+10
View File
@@ -139,6 +139,11 @@ int wolfkmod_vecreg_save(int flags_unused)
wolfkmod_print_curthread("wolfkmod_vecreg_save");
#endif
if (fpu_states == NULL) {
printf("error: wolfkmod_vecreg_save: fpu_states null\n");
return (EINVAL);
}
if (is_fpu_kern_thread(0)) {
/* kernel fpu threads are special, do nothing. They own a
* persistent, dedicated fpu context. */
@@ -189,6 +194,11 @@ void wolfkmod_vecreg_restore(void)
wolfkmod_print_curthread("wolfkmod_vecreg_restore");
#endif
if (fpu_states == NULL) {
printf("error: wolfkmod_vecreg_restore: fpu_states null\n");
return;
}
if (is_fpu_kern_thread(0)) {
/* kernel fpu threads are special, do nothing. They own a
* persistent, dedicated fpu context. */