Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <herbert@gondor.apana.org.au>

+1 -1
+1 -1
crypto/testmgr.c
··· 1869 1869 1870 1870 tfm = crypto_alloc_shash(driver, type, mask); 1871 1871 if (IS_ERR(tfm)) { 1872 - if (PTR_ERR(tfm) == -ENOENT) { 1872 + if (PTR_ERR(tfm) == -ENOENT || PTR_ERR(tfm) == -EEXIST) { 1873 1873 /* 1874 1874 * This algorithm is only available through the ahash 1875 1875 * API, not the shash API, so skip the shash tests.