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

crypto: aesni - clean up mapping of associated data

The gcm(aes-ni) driver is only built for x86_64, which does not make
use of highmem. So testing for PageHighMem is pointless and can be
omitted.

While at it, replace GFP_ATOMIC with the appropriate runtime decided
value based on the context.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
2694e23f 30f2c18e

+5 -4
+5 -4
arch/x86/crypto/aesni-intel_glue.c
··· 667 667 gcm_tfm = &aesni_gcm_tfm_sse; 668 668 669 669 /* Linearize assoc, if not already linear */ 670 - if (req->src->length >= assoclen && req->src->length && 671 - (!PageHighMem(sg_page(req->src)) || 672 - req->src->offset + req->src->length <= PAGE_SIZE)) { 670 + if (req->src->length >= assoclen && req->src->length) { 673 671 scatterwalk_start(&assoc_sg_walk, req->src); 674 672 assoc = scatterwalk_map(&assoc_sg_walk); 675 673 } else { 674 + gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? 675 + GFP_KERNEL : GFP_ATOMIC; 676 + 676 677 /* assoc can be any length, so must be on heap */ 677 - assocmem = kmalloc(assoclen, GFP_ATOMIC); 678 + assocmem = kmalloc(assoclen, flags); 678 679 if (unlikely(!assocmem)) 679 680 return -ENOMEM; 680 681 assoc = assocmem;