CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Xiang Chen <[email protected]>
CC: Herbert Xu <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   c7d102232649226a69dddd58a4942cf13cff4f7c
commit: 5595d0dc1d33b36843166644bb33d94c0e34942e crypto: amlogic - Fix the 
parameter of dma_unmap_sg()
date:   4 months ago
:::::: branch date: 2 days ago
:::::: commit date: 4 months ago
config: x86_64-randconfig-c001-20210731 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
4f71f59bf3d9914188a11d0c41bedbb339d36ff5)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5595d0dc1d33b36843166644bb33d94c0e34942e
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 5595d0dc1d33b36843166644bb33d94c0e34942e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   5 warnings generated.
   fs/nfs/nfs4session.c:127:10: warning: The left operand of '==' is a garbage 
value [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   if (*p == NULL) {
                          ^
   fs/nfs/nfs4session.c:405:2: note: Loop condition is true.  Entering loop body
           for (;;) {
           ^
   fs/nfs/nfs4session.c:406:8: note: Calling 
'nfs41_try_wake_next_slot_table_entry'
                   if (!nfs41_try_wake_next_slot_table_entry(tbl))
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:393:27: note: Calling 'nfs4_alloc_slot'
           struct nfs4_slot *slot = nfs4_alloc_slot(tbl);
                                    ^~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:247:2: note: Loop condition is false.  Exiting loop
           dprintk("--> %s used_slots=%04lx highest_used=%u max_slots=%u\n",
           ^
   include/linux/sunrpc/debug.h:25:2: note: expanded from macro 'dprintk'
           dfprintk(FACILITY, fmt, ##__VA_ARGS__)
           ^
   include/linux/sunrpc/debug.h:70:34: note: expanded from macro 'dfprintk'
   # define dfprintk(fac, fmt, ...)        do {} while (0)
                                           ^
   fs/nfs/nfs4session.c:251:6: note: Assuming 'slotid' is <= field 'max_slotid'
           if (slotid <= tbl->max_slotid) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:251:2: note: Taking true branch
           if (slotid <= tbl->max_slotid) {
           ^
   fs/nfs/nfs4session.c:252:9: note: Calling 'nfs4_find_or_create_slot'
                   ret = nfs4_find_or_create_slot(tbl, slotid, 1, GFP_NOWAIT);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:126:2: note: Loop condition is true.  Entering loop body
           for (;;) {
           ^
   fs/nfs/nfs4session.c:127:7: note: Assuming the condition is true
                   if (*p == NULL) {
                       ^~~~~~~~~~
   fs/nfs/nfs4session.c:127:3: note: Taking true branch
                   if (*p == NULL) {
                   ^
   fs/nfs/nfs4session.c:128:9: note: Calling 'nfs4_new_slot'
                           *p = nfs4_new_slot(tbl, tbl->max_slots,
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:109:9: note: Calling 'kzalloc'
           slot = kzalloc(sizeof(*slot), gfp_mask);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:684:9: note: Uninitialized value stored to field 'next'
           return kmalloc(size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:109:9: note: Returning from 'kzalloc'
           slot = kzalloc(sizeof(*slot), gfp_mask);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:110:6: note: Assuming 'slot' is non-null
           if (slot) {
               ^~~~
   fs/nfs/nfs4session.c:110:2: note: Taking true branch
           if (slot) {
           ^
   fs/nfs/nfs4session.c:128:9: note: Returning from 'nfs4_new_slot'
                           *p = nfs4_new_slot(tbl, tbl->max_slots,
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:130:4: note: Taking false branch
                           if (*p == NULL)
                           ^
   fs/nfs/nfs4session.c:135:7: note: Assuming 'slotid' is not equal to field 
'slot_nr'
                   if (slot->slot_nr == slotid)
                       ^~~~~~~~~~~~~~~~~~~~~~~
   fs/nfs/nfs4session.c:135:3: note: Taking false branch
                   if (slot->slot_nr == slotid)
                   ^
   fs/nfs/nfs4session.c:126:2: note: Loop condition is true.  Entering loop body
           for (;;) {
           ^
   fs/nfs/nfs4session.c:127:10: note: The left operand of '==' is a garbage 
value
                   if (*p == NULL) {
                       ~~ ^
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   drivers/crypto/amlogic/amlogic-gxl-cipher.c:94:22: warning: Value stored to 
'src_sg' during its initialization is never read 
[clang-analyzer-deadcode.DeadStores]
           struct scatterlist *src_sg = areq->src;
                               ^~~~~~   ~~~~~~~~~
   drivers/crypto/amlogic/amlogic-gxl-cipher.c:94:22: note: Value stored to 
'src_sg' during its initialization is never read
           struct scatterlist *src_sg = areq->src;
                               ^~~~~~   ~~~~~~~~~
   drivers/crypto/amlogic/amlogic-gxl-cipher.c:95:22: warning: Value stored to 
'dst_sg' during its initialization is never read 
[clang-analyzer-deadcode.DeadStores]
           struct scatterlist *dst_sg = areq->dst;
                               ^~~~~~   ~~~~~~~~~
   drivers/crypto/amlogic/amlogic-gxl-cipher.c:95:22: note: Value stored to 
'dst_sg' during its initialization is never read
           struct scatterlist *dst_sg = areq->dst;
                               ^~~~~~   ~~~~~~~~~
>> drivers/crypto/amlogic/amlogic-gxl-cipher.c:185:3: warning: Value stored to 
>> 'nr_sgd' is never read [clang-analyzer-deadcode.DeadStores]
                   nr_sgd = nr_sgs;
                   ^        ~~~~~~
   drivers/crypto/amlogic/amlogic-gxl-cipher.c:185:3: note: Value stored to 
'nr_sgd' is never read
                   nr_sgd = nr_sgs;
                   ^        ~~~~~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   9 warnings generated.
   drivers/hid/hid-core.c:1335:24: warning: The result of the left shift is 
undefined due to shifting by '4294967295', which is greater or equal to the 
width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
                                        ^
   drivers/hid/hid-core.c:1717:6: note: Assuming 'buf' is non-null
           if (!buf)
               ^~~~
   drivers/hid/hid-core.c:1717:2: note: Taking false branch
           if (!buf)
           ^
   drivers/hid/hid-core.c:1722:6: note: Assuming 'reqtype' is equal to 
HID_REQ_SET_REPORT
           if (reqtype == HID_REQ_SET_REPORT)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1722:2: note: Taking true branch
           if (reqtype == HID_REQ_SET_REPORT)
           ^
   drivers/hid/hid-core.c:1723:3: note: Calling 'hid_output_report'
                   hid_output_report(report, buf);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1630:14: note: Field 'id' is <= 0
           if (report->id > 0)
                       ^
   drivers/hid/hid-core.c:1630:2: note: Taking false branch
           if (report->id > 0)
           ^
   drivers/hid/hid-core.c:1634:14: note: Assuming 'n' is < field 'maxfield'
           for (n = 0; n < report->maxfield; n++)
                       ^~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1634:2: note: Loop condition is true.  Entering loop 
body
           for (n = 0; n < report->maxfield; n++)
           ^
   drivers/hid/hid-core.c:1635:3: note: Calling 'hid_output_field'
                   hid_output_field(report->device, report->field[n], data);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1600:14: note: Assuming 'n' is < 'count'
           for (n = 0; n < count; n++) {
                       ^~~~~~~~~
   drivers/hid/hid-core.c:1600:2: note: Loop condition is true.  Entering loop 
body
           for (n = 0; n < count; n++) {
           ^
   drivers/hid/hid-core.c:1601:7: note: Assuming field 'logical_minimum' is < 0
                   if (field->logical_minimum < 0) /* signed values */
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1601:3: note: Taking true branch
                   if (field->logical_minimum < 0) /* signed values */
                   ^
   drivers/hid/hid-core.c:1600:14: note: Assuming 'n' is < 'count'
           for (n = 0; n < count; n++) {
                       ^~~~~~~~~
   drivers/hid/hid-core.c:1600:2: note: Loop condition is true.  Entering loop 
body
           for (n = 0; n < count; n++) {
           ^
   drivers/hid/hid-core.c:1601:14: note: Field 'logical_minimum' is < 0
                   if (field->logical_minimum < 0) /* signed values */
                              ^
   drivers/hid/hid-core.c:1601:3: note: Taking true branch
                   if (field->logical_minimum < 0) /* signed values */
                   ^
   drivers/hid/hid-core.c:1603:7: note: Calling 's32ton'
                                     s32ton(field->value[n], size));
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1334:6: note: Assuming 'a' is not equal to 0
           if (a && a != -1)
               ^
   drivers/hid/hid-core.c:1334:6: note: Left side of '&&' is true
   drivers/hid/hid-core.c:1334:11: note: Assuming the condition is true
           if (a && a != -1)
                    ^~~~~~~
   drivers/hid/hid-core.c:1334:2: note: Taking true branch
           if (a && a != -1)
           ^
   drivers/hid/hid-core.c:1335:10: note: Assuming 'value' is < 0
                   return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
                          ^~~~~~~~~
   drivers/hid/hid-core.c:1335:10: note: '?' condition is true
   drivers/hid/hid-core.c:1335:24: note: The result of the left shift is 
undefined due to shifting by '4294967295', which is greater or equal to the 
width of type 'int'
                   return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
                                        ^  ~~~~~~~
   drivers/hid/hid-core.c:1335:40: warning: The result of the left shift is 
undefined due to shifting by '4294967295', which is greater or equal to the 
width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
                                                        ^
   drivers/hid/hid-core.c:1717:6: note: Assuming 'buf' is non-null
           if (!buf)
               ^~~~
   drivers/hid/hid-core.c:1717:2: note: Taking false branch
           if (!buf)
           ^

vim +/nr_sgd +185 drivers/crypto/amlogic/amlogic-gxl-cipher.c

48fe583fe54177 Corentin Labbe 2019-10-17  116  
48fe583fe54177 Corentin Labbe 2019-10-17  117   /*
48fe583fe54177 Corentin Labbe 2019-10-17  118    * The hardware expect a list 
of meson_desc structures.
48fe583fe54177 Corentin Labbe 2019-10-17  119    * The 2 first structures store 
key
48fe583fe54177 Corentin Labbe 2019-10-17  120    * The third stores IV
48fe583fe54177 Corentin Labbe 2019-10-17  121    */
48fe583fe54177 Corentin Labbe 2019-10-17  122   bkeyiv = kzalloc(48, GFP_KERNEL 
| GFP_DMA);
48fe583fe54177 Corentin Labbe 2019-10-17  123   if (!bkeyiv)
48fe583fe54177 Corentin Labbe 2019-10-17  124           return -ENOMEM;
48fe583fe54177 Corentin Labbe 2019-10-17  125  
48fe583fe54177 Corentin Labbe 2019-10-17  126   memcpy(bkeyiv, op->key, 
op->keylen);
48fe583fe54177 Corentin Labbe 2019-10-17  127   keyivlen = op->keylen;
48fe583fe54177 Corentin Labbe 2019-10-17  128  
48fe583fe54177 Corentin Labbe 2019-10-17  129   ivsize = 
crypto_skcipher_ivsize(tfm);
48fe583fe54177 Corentin Labbe 2019-10-17  130   if (areq->iv && ivsize > 0) {
48fe583fe54177 Corentin Labbe 2019-10-17  131           if (ivsize > 
areq->cryptlen) {
48fe583fe54177 Corentin Labbe 2019-10-17  132                   
dev_err(mc->dev, "invalid ivsize=%d vs len=%d\n", ivsize, areq->cryptlen);
56601574c12ff9 Corentin Labbe 2019-11-08  133                   err = -EINVAL;
56601574c12ff9 Corentin Labbe 2019-11-08  134                   goto theend;
48fe583fe54177 Corentin Labbe 2019-10-17  135           }
48fe583fe54177 Corentin Labbe 2019-10-17  136           memcpy(bkeyiv + 32, 
areq->iv, ivsize);
48fe583fe54177 Corentin Labbe 2019-10-17  137           keyivlen = 48;
48fe583fe54177 Corentin Labbe 2019-10-17  138           if (rctx->op_dir == 
MESON_DECRYPT) {
48fe583fe54177 Corentin Labbe 2019-10-17  139                   backup_iv = 
kzalloc(ivsize, GFP_KERNEL);
48fe583fe54177 Corentin Labbe 2019-10-17  140                   if (!backup_iv) 
{
48fe583fe54177 Corentin Labbe 2019-10-17  141                           err = 
-ENOMEM;
48fe583fe54177 Corentin Labbe 2019-10-17  142                           goto 
theend;
48fe583fe54177 Corentin Labbe 2019-10-17  143                   }
48fe583fe54177 Corentin Labbe 2019-10-17  144                   offset = 
areq->cryptlen - ivsize;
48fe583fe54177 Corentin Labbe 2019-10-17  145                   
scatterwalk_map_and_copy(backup_iv, areq->src, offset,
48fe583fe54177 Corentin Labbe 2019-10-17  146                                   
         ivsize, 0);
48fe583fe54177 Corentin Labbe 2019-10-17  147           }
48fe583fe54177 Corentin Labbe 2019-10-17  148   }
48fe583fe54177 Corentin Labbe 2019-10-17  149   if (keyivlen == 24)
48fe583fe54177 Corentin Labbe 2019-10-17  150           keyivlen = 32;
48fe583fe54177 Corentin Labbe 2019-10-17  151  
48fe583fe54177 Corentin Labbe 2019-10-17  152   phykeyiv = 
dma_map_single(mc->dev, bkeyiv, keyivlen,
48fe583fe54177 Corentin Labbe 2019-10-17  153                             
DMA_TO_DEVICE);
56601574c12ff9 Corentin Labbe 2019-11-08  154   err = 
dma_mapping_error(mc->dev, phykeyiv);
56601574c12ff9 Corentin Labbe 2019-11-08  155   if (err) {
48fe583fe54177 Corentin Labbe 2019-10-17  156           dev_err(mc->dev, 
"Cannot DMA MAP KEY IV\n");
56601574c12ff9 Corentin Labbe 2019-11-08  157           goto theend;
48fe583fe54177 Corentin Labbe 2019-10-17  158   }
48fe583fe54177 Corentin Labbe 2019-10-17  159  
48fe583fe54177 Corentin Labbe 2019-10-17  160   tloffset = 0;
48fe583fe54177 Corentin Labbe 2019-10-17  161   eat = 0;
48fe583fe54177 Corentin Labbe 2019-10-17  162   i = 0;
48fe583fe54177 Corentin Labbe 2019-10-17  163   while (keyivlen > eat) {
48fe583fe54177 Corentin Labbe 2019-10-17  164           desc = 
&mc->chanlist[flow].tl[tloffset];
48fe583fe54177 Corentin Labbe 2019-10-17  165           memset(desc, 0, 
sizeof(struct meson_desc));
48fe583fe54177 Corentin Labbe 2019-10-17  166           todo = min(keyivlen - 
eat, 16u);
3d04158814e7a8 Corentin Labbe 2019-11-17  167           desc->t_src = 
cpu_to_le32(phykeyiv + i * 16);
3d04158814e7a8 Corentin Labbe 2019-11-17  168           desc->t_dst = 
cpu_to_le32(i * 16);
3d04158814e7a8 Corentin Labbe 2019-11-17  169           v = (MODE_KEY << 20) | 
DESC_OWN | 16;
3d04158814e7a8 Corentin Labbe 2019-11-17  170           desc->t_status = 
cpu_to_le32(v);
3d04158814e7a8 Corentin Labbe 2019-11-17  171  
48fe583fe54177 Corentin Labbe 2019-10-17  172           eat += todo;
48fe583fe54177 Corentin Labbe 2019-10-17  173           i++;
48fe583fe54177 Corentin Labbe 2019-10-17  174           tloffset++;
48fe583fe54177 Corentin Labbe 2019-10-17  175   }
48fe583fe54177 Corentin Labbe 2019-10-17  176  
48fe583fe54177 Corentin Labbe 2019-10-17  177   if (areq->src == areq->dst) {
48fe583fe54177 Corentin Labbe 2019-10-17  178           nr_sgs = 
dma_map_sg(mc->dev, areq->src, sg_nents(areq->src),
48fe583fe54177 Corentin Labbe 2019-10-17  179                               
DMA_BIDIRECTIONAL);
48fe583fe54177 Corentin Labbe 2019-10-17  180           if (nr_sgs < 0) {
48fe583fe54177 Corentin Labbe 2019-10-17  181                   
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs);
48fe583fe54177 Corentin Labbe 2019-10-17  182                   err = -EINVAL;
48fe583fe54177 Corentin Labbe 2019-10-17  183                   goto theend;
48fe583fe54177 Corentin Labbe 2019-10-17  184           }
48fe583fe54177 Corentin Labbe 2019-10-17 @185           nr_sgd = nr_sgs;
48fe583fe54177 Corentin Labbe 2019-10-17  186   } else {
48fe583fe54177 Corentin Labbe 2019-10-17  187           nr_sgs = 
dma_map_sg(mc->dev, areq->src, sg_nents(areq->src),
48fe583fe54177 Corentin Labbe 2019-10-17  188                               
DMA_TO_DEVICE);
48fe583fe54177 Corentin Labbe 2019-10-17  189           if (nr_sgs < 0 || 
nr_sgs > MAXDESC - 3) {
48fe583fe54177 Corentin Labbe 2019-10-17  190                   
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs);
48fe583fe54177 Corentin Labbe 2019-10-17  191                   err = -EINVAL;
48fe583fe54177 Corentin Labbe 2019-10-17  192                   goto theend;
48fe583fe54177 Corentin Labbe 2019-10-17  193           }
48fe583fe54177 Corentin Labbe 2019-10-17  194           nr_sgd = 
dma_map_sg(mc->dev, areq->dst, sg_nents(areq->dst),
48fe583fe54177 Corentin Labbe 2019-10-17  195                               
DMA_FROM_DEVICE);
48fe583fe54177 Corentin Labbe 2019-10-17  196           if (nr_sgd < 0 || 
nr_sgd > MAXDESC - 3) {
48fe583fe54177 Corentin Labbe 2019-10-17  197                   
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgd);
48fe583fe54177 Corentin Labbe 2019-10-17  198                   err = -EINVAL;
48fe583fe54177 Corentin Labbe 2019-10-17  199                   goto theend;
48fe583fe54177 Corentin Labbe 2019-10-17  200           }
48fe583fe54177 Corentin Labbe 2019-10-17  201   }
48fe583fe54177 Corentin Labbe 2019-10-17  202  
48fe583fe54177 Corentin Labbe 2019-10-17  203   src_sg = areq->src;
48fe583fe54177 Corentin Labbe 2019-10-17  204   dst_sg = areq->dst;
48fe583fe54177 Corentin Labbe 2019-10-17  205   len = areq->cryptlen;
48fe583fe54177 Corentin Labbe 2019-10-17  206   while (src_sg) {
48fe583fe54177 Corentin Labbe 2019-10-17  207           desc = 
&mc->chanlist[flow].tl[tloffset];
48fe583fe54177 Corentin Labbe 2019-10-17  208           memset(desc, 0, 
sizeof(struct meson_desc));
48fe583fe54177 Corentin Labbe 2019-10-17  209  
3d04158814e7a8 Corentin Labbe 2019-11-17  210           desc->t_src = 
cpu_to_le32(sg_dma_address(src_sg));
3d04158814e7a8 Corentin Labbe 2019-11-17  211           desc->t_dst = 
cpu_to_le32(sg_dma_address(dst_sg));
48fe583fe54177 Corentin Labbe 2019-10-17  212           todo = min(len, 
sg_dma_len(src_sg));
3d04158814e7a8 Corentin Labbe 2019-11-17  213           v = (op->keymode << 20) 
| DESC_OWN | todo | (algt->blockmode << 26);
3d04158814e7a8 Corentin Labbe 2019-11-17  214           if (rctx->op_dir)
3d04158814e7a8 Corentin Labbe 2019-11-17  215                   v |= 
DESC_ENCRYPTION;
48fe583fe54177 Corentin Labbe 2019-10-17  216           len -= todo;
48fe583fe54177 Corentin Labbe 2019-10-17  217  
48fe583fe54177 Corentin Labbe 2019-10-17  218           if (!sg_next(src_sg))
3d04158814e7a8 Corentin Labbe 2019-11-17  219                   v |= DESC_LAST;
3d04158814e7a8 Corentin Labbe 2019-11-17  220           desc->t_status = 
cpu_to_le32(v);
48fe583fe54177 Corentin Labbe 2019-10-17  221           tloffset++;
48fe583fe54177 Corentin Labbe 2019-10-17  222           src_sg = 
sg_next(src_sg);
48fe583fe54177 Corentin Labbe 2019-10-17  223           dst_sg = 
sg_next(dst_sg);
48fe583fe54177 Corentin Labbe 2019-10-17  224   }
48fe583fe54177 Corentin Labbe 2019-10-17  225  
48fe583fe54177 Corentin Labbe 2019-10-17  226   
reinit_completion(&mc->chanlist[flow].complete);
48fe583fe54177 Corentin Labbe 2019-10-17  227   mc->chanlist[flow].status = 0;
48fe583fe54177 Corentin Labbe 2019-10-17  228   writel(mc->chanlist[flow].t_phy 
| 2, mc->base + (flow << 2));
48fe583fe54177 Corentin Labbe 2019-10-17  229   
wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete,
48fe583fe54177 Corentin Labbe 2019-10-17  230                                   
          msecs_to_jiffies(500));
48fe583fe54177 Corentin Labbe 2019-10-17  231   if (mc->chanlist[flow].status 
== 0) {
48fe583fe54177 Corentin Labbe 2019-10-17  232           dev_err(mc->dev, "DMA 
timeout for flow %d\n", flow);
48fe583fe54177 Corentin Labbe 2019-10-17  233           err = -EINVAL;
48fe583fe54177 Corentin Labbe 2019-10-17  234   }
48fe583fe54177 Corentin Labbe 2019-10-17  235  
48fe583fe54177 Corentin Labbe 2019-10-17  236   dma_unmap_single(mc->dev, 
phykeyiv, keyivlen, DMA_TO_DEVICE);
48fe583fe54177 Corentin Labbe 2019-10-17  237  
48fe583fe54177 Corentin Labbe 2019-10-17  238   if (areq->src == areq->dst) {
5595d0dc1d33b3 Xiang Chen     2021-03-16  239           dma_unmap_sg(mc->dev, 
areq->src, sg_nents(areq->src), DMA_BIDIRECTIONAL);
48fe583fe54177 Corentin Labbe 2019-10-17  240   } else {
5595d0dc1d33b3 Xiang Chen     2021-03-16  241           dma_unmap_sg(mc->dev, 
areq->src, sg_nents(areq->src), DMA_TO_DEVICE);
5595d0dc1d33b3 Xiang Chen     2021-03-16  242           dma_unmap_sg(mc->dev, 
areq->dst, sg_nents(areq->dst), DMA_FROM_DEVICE);
48fe583fe54177 Corentin Labbe 2019-10-17  243   }
48fe583fe54177 Corentin Labbe 2019-10-17  244  
48fe583fe54177 Corentin Labbe 2019-10-17  245   if (areq->iv && ivsize > 0) {
48fe583fe54177 Corentin Labbe 2019-10-17  246           if (rctx->op_dir == 
MESON_DECRYPT) {
48fe583fe54177 Corentin Labbe 2019-10-17  247                   
memcpy(areq->iv, backup_iv, ivsize);
48fe583fe54177 Corentin Labbe 2019-10-17  248           } else {
48fe583fe54177 Corentin Labbe 2019-10-17  249                   
scatterwalk_map_and_copy(areq->iv, areq->dst,
48fe583fe54177 Corentin Labbe 2019-10-17  250                                   
         areq->cryptlen - ivsize,
48fe583fe54177 Corentin Labbe 2019-10-17  251                                   
         ivsize, 0);
48fe583fe54177 Corentin Labbe 2019-10-17  252           }
48fe583fe54177 Corentin Labbe 2019-10-17  253   }
48fe583fe54177 Corentin Labbe 2019-10-17  254  theend:
453431a54934d9 Waiman Long    2020-08-06  255   kfree_sensitive(bkeyiv);
453431a54934d9 Waiman Long    2020-08-06  256   kfree_sensitive(backup_iv);
48fe583fe54177 Corentin Labbe 2019-10-17  257  
48fe583fe54177 Corentin Labbe 2019-10-17  258   return err;
48fe583fe54177 Corentin Labbe 2019-10-17  259  }
48fe583fe54177 Corentin Labbe 2019-10-17  260  

:::::: The code at line 185 was first introduced by commit
:::::: 48fe583fe54177bfb80f348e2a5cc34c3f710095 crypto: amlogic - Add crypto 
accelerator for amlogic GXL

:::::: TO: Corentin Labbe <[email protected]>
:::::: CC: Herbert Xu <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to