crypto: starfive - Skip unneeded key free
authorJia Jie Ho <jiajie.ho@starfivetech.com>
Tue, 5 Mar 2024 07:10:02 +0000 (15:10 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 2 Apr 2024 02:49:38 +0000 (10:49 +0800)
Skip unneeded kfree_sensitive if RSA module is using falback algo.

Signed-off-by: Jia Jie Ho <jiajie.ho@starfivetech.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/starfive/jh7110-rsa.c

index cf8bda7f0855d911bbc46734fbf69b084c443bfa..e642e948d747855fc01f1fc67afa13303690dafe 100644 (file)
@@ -45,6 +45,9 @@ static inline int starfive_pka_wait_done(struct starfive_cryp_ctx *ctx)
 
 static void starfive_rsa_free_key(struct starfive_rsa_key *key)
 {
+       if (!key->key_sz)
+               return;
+
        kfree_sensitive(key->d);
        kfree_sensitive(key->e);
        kfree_sensitive(key->n);