summaryrefslogtreecommitdiff
path: root/crypto/sm4_generic.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2019-12-18 15:53:01 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-12-27 18:18:03 +0800
commitbb4e37e1168a2bd0366de72f4cdfaf8846a72484 (patch)
tree1327a80e7b98d8cd2e2ceb1413e1aea8e2befd99 /crypto/sm4_generic.c
parent51218bfa6f0bbfdab3df09721a16a55bc1b6da40 (diff)
downloadlinux-crypto-bb4e37e1168a2bd0366de72f4cdfaf8846a72484.tar.gz
linux-crypto-bb4e37e1168a2bd0366de72f4cdfaf8846a72484.zip
crypto: api - Retain alg refcount in crypto_grab_spawn
This patch changes crypto_grab_spawn to retain the reference count on the algorithm. This is because the caller needs to access the algorithm parameters and without the reference count the algorithm can be freed at any time. The reference count will be subsequently dropped by the crypto API once the instance has been registered. The helper crypto_drop_spawn will also conditionally drop the reference count depending on whether it has been registered. Note that the code is actually added to crypto_init_spawn. However, unless the caller activates this by setting spawn->dropref beforehand then nothing happens. The only caller that sets dropref is currently crypto_grab_spawn. Once all legacy users of crypto_init_spawn disappear, then we can kill the dropref flag. Internally each instance will maintain a list of its spawns prior to registration. This memory used by this list is shared with other fields that are only used after registration. In order for this to work a new flag spawn->registered is added to indicate whether spawn->inst can be used. Fixes: af6bf41e2aef ("crypto: api - Add crypto_grab_spawn primitive") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/sm4_generic.c')
0 files changed, 0 insertions, 0 deletions