* [omap-audio:peter/ti-linux-5.4.y/wip 2369/4085] drivers/crypto/sa2ul.c:1018:1-4: alloc with no test, possible model on line 1029
@ 2020-03-07 12:49 kbuild test robot
0 siblings, 0 replies; only message in thread
From: kbuild test robot @ 2020-03-07 12:49 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5031 bytes --]
tree: https://github.com/omap-audio/linux-audio peter/ti-linux-5.4.y/wip
head: f83ef51f0a44eaa8eaf483ed64d97d64432e8fcc
commit: 5b8516f3bedb3e1c273e7747b6e4a85c6e47907a [2369/4085] crypto: sa2ul: Add crypto driver
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
coccinelle warnings: (new ones prefixed by >>)
>> drivers/crypto/sa2ul.c:1018:1-4: alloc with no test, possible model on line 1029
vim +1018 drivers/crypto/sa2ul.c
928
929 static int sa_aes_run(struct ablkcipher_request *req, u8 *iv, int enc)
930 {
931 struct sa_tfm_ctx *ctx =
932 crypto_ablkcipher_ctx(crypto_ablkcipher_reqtfm(req));
933 struct sa_ctx_info *sa_ctx = enc ? &ctx->enc : &ctx->dec;
934 struct sa_crypto_data *pdata = dev_get_drvdata(sa_k3_dev);
935 struct sa_dma_req_ctx req_ctx;
936 struct dma_async_tx_descriptor *tx_in, *tx_out;
937 struct sa_rx_data *rxd;
938 u8 enc_offset;
939 int sg_nents, dst_nents;
940 int psdata_offset;
941 u8 auth_offset = 0;
942 u8 *auth_iv = NULL;
943 u8 *aad = NULL;
944 u8 aad_len = 0;
945 u16 enc_len;
946 u16 auth_len = 0;
947 u32 req_type;
948 u32 *mdptr;
949 size_t pl, ml;
950 struct device *ddev;
951 struct dma_chan *dma_rx;
952 gfp_t flags;
953
954 flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
955 GFP_KERNEL : GFP_ATOMIC;
956
957 enc_offset = 0x0;
958 enc_len = req->nbytes;
959
960 if (enc_len >= 256)
961 dma_rx = pdata->dma_rx2;
962 else
963 dma_rx = pdata->dma_rx1;
964 /* Allocate descriptor & submit packet */
965 sg_nents = sg_nents_for_len(req->src, enc_len);
966 dst_nents = sg_nents_for_len(req->dst, enc_len);
967
968 memcpy(req_ctx.cmdl, sa_ctx->cmdl, sa_ctx->cmdl_size);
969
970 /* Update Command Label */
971 sa_update_cmdl(sa_k3_dev, enc_offset, enc_len,
972 iv, auth_offset, auth_len,
973 auth_iv, aad_len, aad,
974 &sa_ctx->cmdl_upd_info, req_ctx.cmdl);
975
976 /*
977 * Last 2 words in PSDATA will have the crypto alg type &
978 * crypto request pointer
979 */
980 req_type = CRYPTO_ALG_TYPE_ABLKCIPHER;
981 if (enc)
982 req_type |= (SA_REQ_SUBTYPE_ENC << SA_REQ_SUBTYPE_SHIFT);
983 else
984 req_type |= (SA_REQ_SUBTYPE_DEC << SA_REQ_SUBTYPE_SHIFT);
985
986 psdata_offset = sa_ctx->cmdl_size / sizeof(u32);
987 req_ctx.cmdl[psdata_offset++] = req_type;
988
989 ddev = dma_rx->device->dev;
990 /* map the packet */
991 req_ctx.src = req->src;
992 req_ctx.src_nents = dma_map_sg(ddev, req->src, sg_nents, DMA_TO_DEVICE);
993 if (req->src != req->dst)
994 dst_nents = dma_map_sg(ddev, req->dst,
995 sg_nents, DMA_FROM_DEVICE);
996 else
997 dst_nents = req_ctx.src_nents;
998
999 if (unlikely(req_ctx.src_nents != sg_nents)) {
1000 dev_warn_ratelimited(sa_k3_dev, "failed to map tx pkt\n");
1001 return -EIO;
1002 }
1003
1004 req_ctx.dev_data = pdata;
1005 req_ctx.pkt = true;
1006
1007 dma_sync_sg_for_device(pdata->dev, req->src, req_ctx.src_nents,
1008 DMA_TO_DEVICE);
1009
1010 tx_in = dmaengine_prep_slave_sg(dma_rx, req->dst, dst_nents,
1011 DMA_DEV_TO_MEM,
1012 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1013 if (!tx_in) {
1014 dev_err(pdata->dev, "IN prep_slave_sg() failed\n");
1015 return -EINVAL;
1016 }
1017
> 1018 rxd = kzalloc(sizeof(*rxd), GFP_KERNEL);
1019 rxd->req = (void *)req;
1020 rxd->ddev = ddev;
1021 rxd->tx_in = tx_in;
1022 rxd->enc_iv_size = sa_ctx->cmdl_upd_info.enc_iv.size;
1023 rxd->iv_idx = ctx->iv_idx;
1024
1025 /* IN */
1026 tx_in->callback = sa_aes_dma_in_callback;
1027 tx_in->callback_param = rxd;
1028
> 1029 tx_out = dmaengine_prep_slave_sg(pdata->dma_tx, req->src,
1030 req_ctx.src_nents, DMA_MEM_TO_DEV,
1031 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1032 if (!tx_out) {
1033 dev_err(pdata->dev, "OUT prep_slave_sg() failed\n");
1034 return -EINVAL;
1035 }
1036
1037 mdptr = (u32 *)dmaengine_desc_get_metadata_ptr(tx_out, &pl, &ml);
1038
1039 sa_prepare_tx_desc(mdptr, (sa_ctx->cmdl_size + (SA_PSDATA_CTX_WORDS *
1040 sizeof(u32))), req_ctx.cmdl,
1041 sizeof(sa_ctx->epib), sa_ctx->epib);
1042
1043 ml = sa_ctx->cmdl_size + (SA_PSDATA_CTX_WORDS * sizeof(u32));
1044 dmaengine_desc_set_metadata_len(tx_out, 44);
1045
1046 dmaengine_submit(tx_out);
1047 dmaengine_submit(tx_in);
1048
1049 dma_async_issue_pending(dma_rx);
1050 dma_async_issue_pending(pdata->dma_tx);
1051
1052 return -EINPROGRESS;
1053 }
1054
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-07 12:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 12:49 [omap-audio:peter/ti-linux-5.4.y/wip 2369/4085] drivers/crypto/sa2ul.c:1018:1-4: alloc with no test, possible model on line 1029 kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.