Skip to content

Commit 6318fbe

Browse files
committed
crypto: testmgr - Hide ENOENT errors better
The previous patch removed the ENOENT warning at the point of allocation, but the overall self-test warning is still there. Fix all of them by returning zero as the test result. This is safe because if the algorithm has gone away, then it cannot be marked as tested. Fixes: 4eded6d ("crypto: testmgr - Hide ENOENT errors") Signed-off-by: Herbert Xu <[email protected]>
1 parent b81e286 commit 6318fbe

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

crypto/testmgr.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ static int __alg_test_hash(const struct hash_testvec *vecs,
19401940
atfm = crypto_alloc_ahash(driver, type, mask);
19411941
if (IS_ERR(atfm)) {
19421942
if (PTR_ERR(atfm) == -ENOENT)
1943-
return -ENOENT;
1943+
return 0;
19441944
pr_err("alg: hash: failed to allocate transform for %s: %ld\n",
19451945
driver, PTR_ERR(atfm));
19461946
return PTR_ERR(atfm);
@@ -2706,7 +2706,7 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
27062706
tfm = crypto_alloc_aead(driver, type, mask);
27072707
if (IS_ERR(tfm)) {
27082708
if (PTR_ERR(tfm) == -ENOENT)
2709-
return -ENOENT;
2709+
return 0;
27102710
pr_err("alg: aead: failed to allocate transform for %s: %ld\n",
27112711
driver, PTR_ERR(tfm));
27122712
return PTR_ERR(tfm);
@@ -3285,7 +3285,7 @@ static int alg_test_skcipher(const struct alg_test_desc *desc,
32853285
tfm = crypto_alloc_skcipher(driver, type, mask);
32863286
if (IS_ERR(tfm)) {
32873287
if (PTR_ERR(tfm) == -ENOENT)
3288-
return -ENOENT;
3288+
return 0;
32893289
pr_err("alg: skcipher: failed to allocate transform for %s: %ld\n",
32903290
driver, PTR_ERR(tfm));
32913291
return PTR_ERR(tfm);
@@ -3700,7 +3700,7 @@ static int alg_test_cipher(const struct alg_test_desc *desc,
37003700
tfm = crypto_alloc_cipher(driver, type, mask);
37013701
if (IS_ERR(tfm)) {
37023702
if (PTR_ERR(tfm) == -ENOENT)
3703-
return -ENOENT;
3703+
return 0;
37043704
printk(KERN_ERR "alg: cipher: Failed to load transform for "
37053705
"%s: %ld\n", driver, PTR_ERR(tfm));
37063706
return PTR_ERR(tfm);
@@ -3726,7 +3726,7 @@ static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
37263726
acomp = crypto_alloc_acomp(driver, type, mask);
37273727
if (IS_ERR(acomp)) {
37283728
if (PTR_ERR(acomp) == -ENOENT)
3729-
return -ENOENT;
3729+
return 0;
37303730
pr_err("alg: acomp: Failed to load transform for %s: %ld\n",
37313731
driver, PTR_ERR(acomp));
37323732
return PTR_ERR(acomp);
@@ -3740,7 +3740,7 @@ static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
37403740
comp = crypto_alloc_comp(driver, type, mask);
37413741
if (IS_ERR(comp)) {
37423742
if (PTR_ERR(comp) == -ENOENT)
3743-
return -ENOENT;
3743+
return 0;
37443744
pr_err("alg: comp: Failed to load transform for %s: %ld\n",
37453745
driver, PTR_ERR(comp));
37463746
return PTR_ERR(comp);
@@ -3818,7 +3818,7 @@ static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver,
38183818
rng = crypto_alloc_rng(driver, type, mask);
38193819
if (IS_ERR(rng)) {
38203820
if (PTR_ERR(rng) == -ENOENT)
3821-
return -ENOENT;
3821+
return 0;
38223822
printk(KERN_ERR "alg: cprng: Failed to load transform for %s: "
38233823
"%ld\n", driver, PTR_ERR(rng));
38243824
return PTR_ERR(rng);
@@ -3846,12 +3846,11 @@ static int drbg_cavs_test(const struct drbg_testvec *test, int pr,
38463846

38473847
drng = crypto_alloc_rng(driver, type, mask);
38483848
if (IS_ERR(drng)) {
3849+
kfree_sensitive(buf);
38493850
if (PTR_ERR(drng) == -ENOENT)
3850-
goto out_no_rng;
3851+
return 0;
38513852
printk(KERN_ERR "alg: drbg: could not allocate DRNG handle for "
38523853
"%s\n", driver);
3853-
out_no_rng:
3854-
kfree_sensitive(buf);
38553854
return PTR_ERR(drng);
38563855
}
38573856

@@ -4095,7 +4094,7 @@ static int alg_test_kpp(const struct alg_test_desc *desc, const char *driver,
40954094
tfm = crypto_alloc_kpp(driver, type, mask);
40964095
if (IS_ERR(tfm)) {
40974096
if (PTR_ERR(tfm) == -ENOENT)
4098-
return -ENOENT;
4097+
return 0;
40994098
pr_err("alg: kpp: Failed to load tfm for %s: %ld\n",
41004099
driver, PTR_ERR(tfm));
41014100
return PTR_ERR(tfm);
@@ -4325,7 +4324,7 @@ static int alg_test_akcipher(const struct alg_test_desc *desc,
43254324
tfm = crypto_alloc_akcipher(driver, type, mask);
43264325
if (IS_ERR(tfm)) {
43274326
if (PTR_ERR(tfm) == -ENOENT)
4328-
return -ENOENT;
4327+
return 0;
43294328
pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n",
43304329
driver, PTR_ERR(tfm));
43314330
return PTR_ERR(tfm);

0 commit comments

Comments
 (0)