提交 5258de8a 编写于 作者: T Tom Lendacky 提交者: Herbert Xu

crypto: ccp - Apply appropriate gfp_t type to memory allocations

Fix some memory allocations to use the appropriate gfp_t type based
on the CRYPTO_TFM_REQ_MAY_SLEEP flag.
Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 d16b8700
...@@ -61,6 +61,7 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes, ...@@ -61,6 +61,7 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
unsigned int block_size = unsigned int block_size =
crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
unsigned int len, need_pad, sg_count; unsigned int len, need_pad, sg_count;
gfp_t gfp;
int ret; int ret;
if (!ctx->u.aes.key_len) if (!ctx->u.aes.key_len)
...@@ -99,7 +100,9 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes, ...@@ -99,7 +100,9 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
* possible data pieces (buffer, input data, padding) * possible data pieces (buffer, input data, padding)
*/ */
sg_count = (nbytes) ? sg_nents(req->src) + 2 : 2; sg_count = (nbytes) ? sg_nents(req->src) + 2 : 2;
ret = sg_alloc_table(&rctx->data_sg, sg_count, GFP_KERNEL); gfp = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
GFP_KERNEL : GFP_ATOMIC;
ret = sg_alloc_table(&rctx->data_sg, sg_count, gfp);
if (ret) if (ret)
return ret; return ret;
......
...@@ -128,6 +128,7 @@ static int ccp_do_sha_update(struct ahash_request *req, unsigned int nbytes, ...@@ -128,6 +128,7 @@ static int ccp_do_sha_update(struct ahash_request *req, unsigned int nbytes,
unsigned int block_size = unsigned int block_size =
crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
unsigned int len, sg_count; unsigned int len, sg_count;
gfp_t gfp;
int ret; int ret;
if (!final && ((nbytes + rctx->buf_count) <= block_size)) { if (!final && ((nbytes + rctx->buf_count) <= block_size)) {
...@@ -156,7 +157,9 @@ static int ccp_do_sha_update(struct ahash_request *req, unsigned int nbytes, ...@@ -156,7 +157,9 @@ static int ccp_do_sha_update(struct ahash_request *req, unsigned int nbytes,
* possible data pieces (hmac ipad, buffer, input data) * possible data pieces (hmac ipad, buffer, input data)
*/ */
sg_count = (nbytes) ? sg_nents(req->src) + 2 : 2; sg_count = (nbytes) ? sg_nents(req->src) + 2 : 2;
ret = sg_alloc_table(&rctx->data_sg, sg_count, GFP_KERNEL); gfp = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
GFP_KERNEL : GFP_ATOMIC;
ret = sg_alloc_table(&rctx->data_sg, sg_count, gfp);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册