forked from wolfSSL/wolfssl
linuxkm/module_hooks.c: separate cleanup into static libwolfssl_cleanup(), and call it from wolfssl_init() if wolfcrypt_test() fails.
This commit is contained in:
@@ -31,6 +31,26 @@
|
|||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int libwolfssl_cleanup(void) {
|
||||||
|
int ret;
|
||||||
|
#ifdef WOLFCRYPT_ONLY
|
||||||
|
ret = wolfCrypt_Cleanup();
|
||||||
|
if (ret != 0)
|
||||||
|
pr_err("wolfCrypt_Cleanup() failed: %s", wc_GetErrorString(ret));
|
||||||
|
else
|
||||||
|
pr_info("wolfCrypt " LIBWOLFSSL_VERSION_STRING " cleanup complete.\n");
|
||||||
|
#else
|
||||||
|
ret = wolfSSL_Cleanup();
|
||||||
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
|
pr_err("wolfSSL_Cleanup() failed: %s", wc_GetErrorString(ret));
|
||||||
|
else
|
||||||
|
pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " cleanup complete.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
|
||||||
static int __init wolfssl_init(void)
|
static int __init wolfssl_init(void)
|
||||||
#else
|
#else
|
||||||
@@ -55,7 +75,8 @@ static int wolfssl_init(void)
|
|||||||
#ifndef NO_CRYPT_TEST
|
#ifndef NO_CRYPT_TEST
|
||||||
ret = wolfcrypt_test(NULL);
|
ret = wolfcrypt_test(NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pr_err("wolfcrypt self-test failed.");
|
pr_err("wolfcrypt self-test failed with return code %d.", ret);
|
||||||
|
(void)libwolfssl_cleanup();
|
||||||
msleep(10);
|
msleep(10);
|
||||||
return -ENOTRECOVERABLE;
|
return -ENOTRECOVERABLE;
|
||||||
}
|
}
|
||||||
@@ -81,21 +102,7 @@ static void __exit wolfssl_exit(void)
|
|||||||
static void wolfssl_exit(void)
|
static void wolfssl_exit(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int ret;
|
(void)libwolfssl_cleanup();
|
||||||
#ifdef WOLFCRYPT_ONLY
|
|
||||||
ret = wolfCrypt_Cleanup();
|
|
||||||
if (ret != 0)
|
|
||||||
pr_err("wolfCrypt_Cleanup() failed: %s", wc_GetErrorString(ret));
|
|
||||||
else
|
|
||||||
pr_info("wolfCrypt " LIBWOLFSSL_VERSION_STRING " cleanup complete.\n");
|
|
||||||
#else
|
|
||||||
ret = wolfSSL_Cleanup();
|
|
||||||
if (ret != WOLFSSL_SUCCESS)
|
|
||||||
pr_err("wolfSSL_Cleanup() failed: %s", wc_GetErrorString(ret));
|
|
||||||
else
|
|
||||||
pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " cleanup complete.\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user