From 733c2fd18427335376c9c62cda03a018a6dbb8e4 Mon Sep 17 00:00:00 2001 From: tanghui20 Date: Fri, 9 Aug 2019 20:52:09 +0800 Subject: [PATCH] ACC: apply for memory using "GFP_KERNEL"in the lock driver inclusion category: bugfix bugzilla: NA CVE: NA Using GFP_KERNEL when applying for memory may sleep, if this action may trigger a deadlock in the lock Feature or Bugfix:Bugfix Signed-off-by: tanghui20 Reviewed-by: xuzaibo Signed-off-by: lingmingqiang Reviewed-by: lingmingqiang Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/crypto/hisilicon/qm.c | 6 +++--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 0a0851b688fc..d2783c269096 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2339,10 +2339,10 @@ int hisi_qm_start(struct hisi_qm *qm) if (!qm->qp_bitmap) { qm->qp_bitmap = devm_kcalloc(dev, BITS_TO_LONGS(qm->qp_num), - sizeof(long), GFP_KERNEL); + sizeof(long), GFP_ATOMIC); qm->qp_array = devm_kcalloc(dev, qm->qp_num, sizeof(struct hisi_qp *), - GFP_KERNEL); + GFP_ATOMIC); if (!qm->qp_bitmap || !qm->qp_array) { ret = -ENOMEM; goto err_unlock; @@ -2364,7 +2364,7 @@ int hisi_qm_start(struct hisi_qm *qm) QMC_ALIGN(sizeof(struct qm_cqc) * qm->qp_num); qm->qdma.va = dma_alloc_coherent(dev, qm->qdma.size, &qm->qdma.dma, - GFP_KERNEL | __GFP_ZERO); + GFP_ATOMIC | __GFP_ZERO); dev_dbg(dev, "allocate qm dma buf(va=%pK, dma=%pad, size=%lx)\n", qm->qdma.va, &qm->qdma.dma, qm->qdma.size); if (!qm->qdma.va) { diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 36792cf20d21..d7b9e6af0359 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -200,13 +200,13 @@ static int hisi_sec_create_qp_ctx(struct hisi_qm *qm, struct hisi_sec_ctx *ctx, atomic_set(&qp_ctx->req_cnt, 0); qp_ctx->req_bitmap = kcalloc(BITS_TO_LONGS(QM_Q_DEPTH), sizeof(long), - GFP_KERNEL); + GFP_ATOMIC); if (!qp_ctx->req_bitmap) { ret = -ENOMEM; goto err_qm_release_qp; } - qp_ctx->req_list = kcalloc(QM_Q_DEPTH, sizeof(void *), GFP_KERNEL); + qp_ctx->req_list = kcalloc(QM_Q_DEPTH, sizeof(void *), GFP_ATOMIC); if (!qp_ctx->req_list) { ret = -ENOMEM; goto err_free_req_bitmap; -- GitLab