aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/crypto/hisilicon/sec/sec_algs.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
index 32c6c02cb9ae..cdc4f9a171d9 100644
--- a/drivers/crypto/hisilicon/sec/sec_algs.c
+++ b/drivers/crypto/hisilicon/sec/sec_algs.c
@@ -808,13 +808,6 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
808 * more refined but this is unlikely to happen so no need. 808 * more refined but this is unlikely to happen so no need.
809 */ 809 */
810 810
811 /* Cleanup - all elements in pointer arrays have been coppied */
812 kfree(splits_in_nents);
813 kfree(splits_in);
814 kfree(splits_out_nents);
815 kfree(splits_out);
816 kfree(split_sizes);
817
818 /* Grab a big lock for a long time to avoid concurrency issues */ 811 /* Grab a big lock for a long time to avoid concurrency issues */
819 mutex_lock(&queue->queuelock); 812 mutex_lock(&queue->queuelock);
820 813
@@ -829,13 +822,13 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
829 (!queue->havesoftqueue || 822 (!queue->havesoftqueue ||
830 kfifo_avail(&queue->softqueue) > steps)) || 823 kfifo_avail(&queue->softqueue) > steps)) ||
831 !list_empty(&ctx->backlog)) { 824 !list_empty(&ctx->backlog)) {
825 ret = -EBUSY;
832 if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { 826 if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
833 list_add_tail(&sec_req->backlog_head, &ctx->backlog); 827 list_add_tail(&sec_req->backlog_head, &ctx->backlog);
834 mutex_unlock(&queue->queuelock); 828 mutex_unlock(&queue->queuelock);
835 return -EBUSY; 829 goto out;
836 } 830 }
837 831
838 ret = -EBUSY;
839 mutex_unlock(&queue->queuelock); 832 mutex_unlock(&queue->queuelock);
840 goto err_free_elements; 833 goto err_free_elements;
841 } 834 }
@@ -844,7 +837,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
844 if (ret) 837 if (ret)
845 goto err_free_elements; 838 goto err_free_elements;
846 839
847 return -EINPROGRESS; 840 ret = -EINPROGRESS;
841out:
842 /* Cleanup - all elements in pointer arrays have been copied */
843 kfree(splits_in_nents);
844 kfree(splits_in);
845 kfree(splits_out_nents);
846 kfree(splits_out);
847 kfree(split_sizes);
848 return ret;
848 849
849err_free_elements: 850err_free_elements:
850 list_for_each_entry_safe(el, temp, &sec_req->elements, head) { 851 list_for_each_entry_safe(el, temp, &sec_req->elements, head) {