Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions bsdkm/wolfkmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ static int wolfkdriv_attach(device_t dev)

attach_out:
if (error) {
wolfkdriv_unregister(softc);
device_printf(dev, "error: attach_out: %d\n", error);
(void)wolfkmod_cleanup();
wolfkdriv_unregister(softc);
}
Comment on lines 493 to 497

return (error);
Expand All @@ -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);
ret = wolfkmod_cleanup();

if (ret == 0) {
/* unregister wolfcrypt algs */
softc = device_get_softc(dev);
wolfkdriv_unregister(softc);
}

wolfkdriv_unregister(softc);
Comment on lines +507 to +510
#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);
Expand Down Expand Up @@ -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));

Expand All @@ -812,6 +812,11 @@ static int wolfkdriv_cbc_work(device_t dev, wolfkdriv_session_t * session,
error);
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */

if (error < 0) {
/* convert wolfcrypt errors to EINVAL. */
error = EINVAL;
}

return (error);
}

Expand Down Expand Up @@ -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));

Expand All @@ -989,6 +995,11 @@ static int wolfkdriv_gcm_work(device_t dev, wolfkdriv_session_t * session,
error);
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */

if (error < 0) {
/* convert wolfcrypt errors to EINVAL. */
error = EINVAL;
}

return (error);
}

Expand Down
2 changes: 1 addition & 1 deletion bsdkm/wolfkmod_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 10 additions & 0 deletions bsdkm/x86_vecreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ int wolfkmod_vecreg_save(int flags_unused)
wolfkmod_print_curthread("wolfkmod_vecreg_save");
#endif

if (fpu_states == NULL) {
printf("info : wolfkmod_vecreg_save: fpu_states null\n");
return (EINVAL);
}
Comment on lines +142 to +145

if (is_fpu_kern_thread(0)) {
/* kernel fpu threads are special, do nothing. They own a
* persistent, dedicated fpu context. */
Expand Down Expand Up @@ -189,6 +194,11 @@ void wolfkmod_vecreg_restore(void)
wolfkmod_print_curthread("wolfkmod_vecreg_restore");
#endif

if (fpu_states == NULL) {
printf("info: wolfkmod_vecreg_restore: fpu_states null\n");
return;
}
Comment on lines +197 to +200

if (is_fpu_kern_thread(0)) {
/* kernel fpu threads are special, do nothing. They own a
* persistent, dedicated fpu context. */
Expand Down
Loading