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.

nvme-auth: host: remove allocation of crypto_shash

Now that the crypto_shash that is being allocated in
nvme_auth_process_dhchap_challenge() and stored in the
struct nvme_dhchap_queue_context is no longer used, remove it.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Eric Biggers and committed by
Keith Busch
ac9a49cf c4f216c2

+2 -27
+2 -27
drivers/nvme/host/auth.c
··· 7 7 #include <linux/base64.h> 8 8 #include <linux/prandom.h> 9 9 #include <linux/unaligned.h> 10 - #include <crypto/hash.h> 11 10 #include <crypto/dh.h> 12 11 #include "nvme.h" 13 12 #include "fabrics.h" ··· 21 22 struct list_head entry; 22 23 struct work_struct auth_work; 23 24 struct nvme_ctrl *ctrl; 24 - struct crypto_shash *shash_tfm; 25 25 struct crypto_kpp *dh_tfm; 26 26 struct nvme_dhchap_key *transformed_key; 27 27 void *buf; ··· 181 183 return -EPROTO; 182 184 } 183 185 184 - if (chap->hash_id == data->hashid && chap->shash_tfm && 185 - !strcmp(crypto_shash_alg_name(chap->shash_tfm), hmac_name) && 186 - crypto_shash_digestsize(chap->shash_tfm) == data->hl) { 186 + if (chap->hash_id == data->hashid && chap->hash_len == data->hl) { 187 187 dev_dbg(ctrl->device, 188 188 "qid %d: reuse existing hash %s\n", 189 189 chap->qid, hmac_name); 190 190 goto select_kpp; 191 191 } 192 192 193 - /* Reset if hash cannot be reused */ 194 - if (chap->shash_tfm) { 195 - crypto_free_shash(chap->shash_tfm); 196 - chap->hash_id = 0; 197 - chap->hash_len = 0; 198 - } 199 - chap->shash_tfm = crypto_alloc_shash(hmac_name, 0, 200 - CRYPTO_ALG_ALLOCATES_MEMORY); 201 - if (IS_ERR(chap->shash_tfm)) { 202 - dev_warn(ctrl->device, 203 - "qid %d: failed to allocate hash %s, error %ld\n", 204 - chap->qid, hmac_name, PTR_ERR(chap->shash_tfm)); 205 - chap->shash_tfm = NULL; 206 - chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; 207 - return -ENOMEM; 208 - } 209 - 210 - if (crypto_shash_digestsize(chap->shash_tfm) != data->hl) { 193 + if (nvme_auth_hmac_hash_len(data->hashid) != data->hl) { 211 194 dev_warn(ctrl->device, 212 195 "qid %d: invalid hash length %d\n", 213 196 chap->qid, data->hl); 214 - crypto_free_shash(chap->shash_tfm); 215 - chap->shash_tfm = NULL; 216 197 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; 217 198 return -EPROTO; 218 199 } ··· 635 658 { 636 659 nvme_auth_reset_dhchap(chap); 637 660 chap->authenticated = false; 638 - if (chap->shash_tfm) 639 - crypto_free_shash(chap->shash_tfm); 640 661 if (chap->dh_tfm) 641 662 crypto_free_kpp(chap->dh_tfm); 642 663 }