From 19a9670aaa790afea6b2ad4ff8df63e159b779ff Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Mon, 8 Jun 2026 17:37:13 -0500 Subject: [PATCH] fix F-1234: IS_ERR Used on NULL-Returning Kernel Crypto Request Allocation Functions. --- linuxkm/lkcapi_aes_glue.c | 22 ++++++++++------------ linuxkm/lkcapi_dh_glue.c | 8 ++------ linuxkm/lkcapi_ecdh_glue.c | 8 ++------ linuxkm/lkcapi_ecdsa_glue.c | 8 ++------ linuxkm/lkcapi_rsa_glue.c | 12 ++++-------- 5 files changed, 20 insertions(+), 38 deletions(-) diff --git a/linuxkm/lkcapi_aes_glue.c b/linuxkm/lkcapi_aes_glue.c index 574c7d20de..6bd68978e0 100644 --- a/linuxkm/lkcapi_aes_glue.c +++ b/linuxkm/lkcapi_aes_glue.c @@ -3118,10 +3118,10 @@ static int linuxkm_test_aescbc(void) } req = skcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + ret = -ENOMEM; pr_err("error: allocating AES skcipher request %s failed\n", WOLFKM_AESCBC_DRIVER); - req = NULL; goto test_cbc_end; } @@ -3320,10 +3320,10 @@ static int linuxkm_test_aescfb(void) } req = skcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + ret = -ENOMEM; pr_err("error: allocating AES skcipher request %s failed\n", WOLFKM_AESCFB_DRIVER); - req = NULL; goto test_cfb_end; } @@ -3586,10 +3586,10 @@ static int linuxkm_test_aesgcm(void) } req = aead_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + ret = -ENOMEM; pr_err("error: allocating AES aead request %s failed: %ld\n", WOLFKM_AESCBC_DRIVER, PTR_ERR(req)); - req = NULL; goto test_gcm_end; } @@ -4209,11 +4209,10 @@ static int aes_xts_128_test(void) } req = skcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { - ret = PTR_ERR(req); + if (! req) { + ret = -ENOMEM; pr_err("error: allocating AES skcipher request %s failed: %d\n", WOLFKM_AESXTS_DRIVER, ret); - req = NULL; goto test_xts_end; } @@ -4690,11 +4689,10 @@ static int aes_xts_256_test(void) } req = skcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { - ret = PTR_ERR(req); + if (! req) { + ret = -ENOMEM; pr_err("error: allocating AES skcipher request %s failed: %d\n", WOLFKM_AESXTS_DRIVER, ret); - req = NULL; goto test_xts_end; } diff --git a/linuxkm/lkcapi_dh_glue.c b/linuxkm/lkcapi_dh_glue.c index 581776b230..5fb3dd2ffd 100644 --- a/linuxkm/lkcapi_dh_glue.c +++ b/linuxkm/lkcapi_dh_glue.c @@ -2878,14 +2878,10 @@ static int linuxkm_test_kpp_driver(const char * driver, } req = kpp_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + test_rc = -ENOMEM; pr_err("error: allocating kpp request %s failed\n", driver); - if (PTR_ERR(req) == -ENOMEM) - test_rc = MEMORY_E; - else - test_rc = BAD_FUNC_ARG; - req = NULL; goto test_kpp_end; } diff --git a/linuxkm/lkcapi_ecdh_glue.c b/linuxkm/lkcapi_ecdh_glue.c index 24755917a5..f562285306 100644 --- a/linuxkm/lkcapi_ecdh_glue.c +++ b/linuxkm/lkcapi_ecdh_glue.c @@ -905,14 +905,10 @@ static int linuxkm_test_ecdh_nist_driver(const char * driver, } req = kpp_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + test_rc = -ENOMEM; pr_err("error: allocating kpp request %s failed\n", driver); - if (PTR_ERR(req) == -ENOMEM) - test_rc = MEMORY_E; - else - test_rc = BAD_FUNC_ARG; - req = NULL; goto test_ecdh_nist_end; } diff --git a/linuxkm/lkcapi_ecdsa_glue.c b/linuxkm/lkcapi_ecdsa_glue.c index 13a0e90be5..62e2eca120 100644 --- a/linuxkm/lkcapi_ecdsa_glue.c +++ b/linuxkm/lkcapi_ecdsa_glue.c @@ -763,14 +763,10 @@ static int linuxkm_test_ecdsa_nist_driver(const char * driver, } req = akcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + test_rc = -ENOMEM; pr_err("error: allocating akcipher request %s failed\n", driver); - if (PTR_ERR(req) == -ENOMEM) - test_rc = MEMORY_E; - else - test_rc = BAD_FUNC_ARG; - req = NULL; goto test_ecdsa_nist_end; } diff --git a/linuxkm/lkcapi_rsa_glue.c b/linuxkm/lkcapi_rsa_glue.c index ac7f8ff5c7..f76a8cbee9 100644 --- a/linuxkm/lkcapi_rsa_glue.c +++ b/linuxkm/lkcapi_rsa_glue.c @@ -2267,10 +2267,10 @@ static int linuxkm_test_rsa_driver(const char * driver, int nbits) } req = akcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + ret = -ENOMEM; pr_err("error: allocating akcipher request %s failed\n", driver); - req = NULL; goto test_rsa_end; } @@ -2694,14 +2694,10 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits, } req = akcipher_request_alloc(tfm, GFP_KERNEL); - if (IS_ERR(req)) { + if (! req) { + test_rc = -ENOMEM; pr_err("error: allocating akcipher request %s failed\n", driver); - if (PTR_ERR(req) == -ENOMEM) - test_rc = MEMORY_E; - else - test_rc = BAD_FUNC_ARG; - req = NULL; goto test_pkcs1_end; }