From: Herbert Xu Date: Thu, 15 May 2025 05:54:49 +0000 (+0800) Subject: crypto: testmgr - Ignore EEXIST on shash allocation X-Git-Tag: v6.16-rc1~206^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e69871836669177d2d2a5acec5c8dca3319d2f1;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/crypto/testmgr.c b/crypto/testmgr.c index fc28000c27f5a..ee682ad50e347 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1869,7 +1869,7 @@ static int alloc_shash(const char *driver, u32 type, u32 mask, tfm = crypto_alloc_shash(driver, type, mask); if (IS_ERR(tfm)) { - if (PTR_ERR(tfm) == -ENOENT) { + if (PTR_ERR(tfm) == -ENOENT || PTR_ERR(tfm) == -EEXIST) { /* * This algorithm is only available through the ahash * API, not the shash API, so skip the shash tests.