Skip to content

Commit 8e69871

Browse files
committed
crypto: testmgr - Ignore EEXIST on shash allocation
Soon hmac will support ahash. For compatibility hmac still supports shash so it is possible for two hmac algorithms to be registered at the same time. The shash algorithm will have the driver name "hmac-shash(XXX-driver)". Due to a quirk in the API, there is no way to locate the shash algorithm using the name "hmac(XXX-driver)". It has to be addressed as either "hmac(XXX)" or "hmac-shash(XXX-driver)". Looking it up with "hmac(XXX-driver)" will simply trigger the creation of another instance, and on the second instantiation this will fail with EEXIST. Catch the error EEXIST along with ENOENT since it is expected. If a real shash algorithm came this way, it would be addressed using the proper name "hmac-shash(XXX-driver)". Signed-off-by: Herbert Xu <[email protected]>
1 parent 91b6ff5 commit 8e69871

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crypto/testmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ static int alloc_shash(const char *driver, u32 type, u32 mask,
18691869

18701870
tfm = crypto_alloc_shash(driver, type, mask);
18711871
if (IS_ERR(tfm)) {
1872-
if (PTR_ERR(tfm) == -ENOENT) {
1872+
if (PTR_ERR(tfm) == -ENOENT || PTR_ERR(tfm) == -EEXIST) {
18731873
/*
18741874
* This algorithm is only available through the ahash
18751875
* API, not the shash API, so skip the shash tests.

0 commit comments

Comments
 (0)