:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: 
drivers/spi/spi-stm32-qspi.c:633:21: warning: use of uninitialized value 'ret' 
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Patrice Chotard <[email protected]>
CC: Mark Brown <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/ci.git 
v3_20220816_patrice_chotard_spi_stm32_qspi_use_qspi_bus_as_8_lines_communication_channel
head:   b051161f44d414e736fa2b011245441bae9babd7
commit: b051161f44d414e736fa2b011245441bae9babd7 [13/13] spi: stm32_qspi: Add 
transfer_one_message() spi callback
:::::: branch date: 10 days ago
:::::: commit date: 10 days ago
config: arm-randconfig-c002-20220901 
(https://download.01.org/0day-ci/archive/20220902/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
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
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/ci.git/commit/?id=b051161f44d414e736fa2b011245441bae9babd7
        git remote add broonie-ci 
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/ci.git
        git fetch --no-tags broonie-ci 
v3_20220816_patrice_chotard_spi_stm32_qspi_use_qspi_bus_as_8_lines_communication_channel
        git checkout b051161f44d414e736fa2b011245441bae9babd7
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross 
ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

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

gcc_analyzer warnings: (new ones prefixed by >>)
   In function 'stm32_qspi_transfer_one_message':
   cc1: warning: use of uninitialized value '<unknown>' [CWE-457] 
[-Wanalyzer-use-of-uninitialized-value]
     'stm32_qspi_transfer_one_message': events 1-6
       |
       |drivers/spi/spi-stm32-qspi.c:573:12:
       |  573 |         if (!spi->cs_gpiod)
       |      |            ^
       |      |            |
       |      |            (1) following 'false' branch...
       |......
       |  576 |         mutex_lock(&qspi->lock);
       |      |         ~~~~~~~~~~
       |      |         |
       |      |         (2) ...to here
       |......
       |  595 |                 if (transfer->dummy_data) {
       |      |                    ~
       |      |                    |
       |      |                    (3) following 'true' branch...
       |  596 |                         op.dummy.buswidth = transfer->tx_nbits;
       |      |                         ~~
       |      |                         |
       |      |                         (4) ...to here
       |......
       |  601 |                         if 
(list_is_last(&transfer->transfer_list, &msg->transfers))
       |      |                            ~
       |      |                            |
       |      |                            (5) following 'true' branch...
       |  602 |                                 goto end_of_transfer;
       |      |                                 ~~~~
       |      |                                 |
       |      |                                 (6) ...to here
       |
     'stm32_qspi_transfer_one_message': event 7
       |
       |cc1:
       | (7): use of uninitialized value '<unknown>' here
       |
>> drivers/spi/spi-stm32-qspi.c:633:21: warning: use of uninitialized value 
>> 'ret' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
     633 |         msg->status = ret;
         |         ~~~~~~~~~~~~^~~~~
     'stm32_qspi_transfer_one_message': events 1-8
       |
       |  571 |         int ret;
       |      |             ^~~
       |      |             |
       |      |             (1) region created on stack here
       |  572 | 
       |  573 |         if (!spi->cs_gpiod)
       |      |            ~ 
       |      |            |
       |      |            (2) following 'false' branch...
       |......
       |  576 |         mutex_lock(&qspi->lock);
       |      |         ~~~~~~~~~~
       |      |         |
       |      |         (3) ...to here
       |......
       |  595 |                 if (transfer->dummy_data) {
       |      |                    ~
       |      |                    |
       |      |                    (4) following 'true' branch...
       |  596 |                         op.dummy.buswidth = transfer->tx_nbits;
       |      |                         ~~
       |      |                         |
       |      |                         (5) ...to here
       |......
       |  601 |                         if 
(list_is_last(&transfer->transfer_list, &msg->transfers))
       |      |                            ~
       |      |                            |
       |      |                            (6) following 'true' branch...
       |  602 |                                 goto end_of_transfer;
       |      |                                 ~~~~
       |      |                                 |
       |      |                                 (7) ...to here
       |......
       |  633 |         msg->status = ret;
       |      |         ~~~~~~~~~~~~~~~~~
       |      |                     |
       |      |                     (8) use of uninitialized value 'ret' here
       |

vim +/ret +633 drivers/spi/spi-stm32-qspi.c

b051161f44d414e Patrice Chotard 2022-08-16  563  
b051161f44d414e Patrice Chotard 2022-08-16  564  static int 
stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
b051161f44d414e Patrice Chotard 2022-08-16  565                                 
           struct spi_message *msg)
b051161f44d414e Patrice Chotard 2022-08-16  566  {
b051161f44d414e Patrice Chotard 2022-08-16  567         struct stm32_qspi *qspi 
= spi_controller_get_devdata(ctrl);
b051161f44d414e Patrice Chotard 2022-08-16  568         struct spi_transfer 
*transfer;
b051161f44d414e Patrice Chotard 2022-08-16  569         struct spi_device *spi 
= msg->spi;
b051161f44d414e Patrice Chotard 2022-08-16  570         struct spi_mem_op op;
b051161f44d414e Patrice Chotard 2022-08-16  571         int ret;
b051161f44d414e Patrice Chotard 2022-08-16  572  
b051161f44d414e Patrice Chotard 2022-08-16  573         if (!spi->cs_gpiod)
b051161f44d414e Patrice Chotard 2022-08-16  574                 return 
-EOPNOTSUPP;
b051161f44d414e Patrice Chotard 2022-08-16  575  
b051161f44d414e Patrice Chotard 2022-08-16  576         mutex_lock(&qspi->lock);
b051161f44d414e Patrice Chotard 2022-08-16  577  
b051161f44d414e Patrice Chotard 2022-08-16  578         
gpiod_set_value_cansleep(spi->cs_gpiod, true);
b051161f44d414e Patrice Chotard 2022-08-16  579  
b051161f44d414e Patrice Chotard 2022-08-16  580         
list_for_each_entry(transfer, &msg->transfers, transfer_list) {
b051161f44d414e Patrice Chotard 2022-08-16  581                 u8 dummy_bytes 
= 0;
b051161f44d414e Patrice Chotard 2022-08-16  582  
b051161f44d414e Patrice Chotard 2022-08-16  583                 memset(&op, 0, 
sizeof(op));
b051161f44d414e Patrice Chotard 2022-08-16  584  
b051161f44d414e Patrice Chotard 2022-08-16  585                 
dev_dbg(qspi->dev, "tx_buf:%p tx_nbits:%d rx_buf:%p rx_nbits:%d len:%d 
dummy_data:%d\n",
b051161f44d414e Patrice Chotard 2022-08-16  586                         
transfer->tx_buf, transfer->tx_nbits,
b051161f44d414e Patrice Chotard 2022-08-16  587                         
transfer->rx_buf, transfer->rx_nbits,
b051161f44d414e Patrice Chotard 2022-08-16  588                         
transfer->len, transfer->dummy_data);
b051161f44d414e Patrice Chotard 2022-08-16  589  
b051161f44d414e Patrice Chotard 2022-08-16  590                 /*
b051161f44d414e Patrice Chotard 2022-08-16  591                  * QSPI 
hardware supports dummy bytes transfer.
b051161f44d414e Patrice Chotard 2022-08-16  592                  * If current 
transfer is dummy byte, merge it with the next
b051161f44d414e Patrice Chotard 2022-08-16  593                  * transfer in 
order to take into account QSPI block constraint
b051161f44d414e Patrice Chotard 2022-08-16  594                  */
b051161f44d414e Patrice Chotard 2022-08-16  595                 if 
(transfer->dummy_data) {
b051161f44d414e Patrice Chotard 2022-08-16  596                         
op.dummy.buswidth = transfer->tx_nbits;
b051161f44d414e Patrice Chotard 2022-08-16  597                         
op.dummy.nbytes = transfer->len;
b051161f44d414e Patrice Chotard 2022-08-16  598                         
dummy_bytes = transfer->len;
b051161f44d414e Patrice Chotard 2022-08-16  599  
b051161f44d414e Patrice Chotard 2022-08-16  600                         /* if 
happens, means that message is not correctly built */
b051161f44d414e Patrice Chotard 2022-08-16  601                         if 
(list_is_last(&transfer->transfer_list, &msg->transfers))
b051161f44d414e Patrice Chotard 2022-08-16  602                                 
goto end_of_transfer;
b051161f44d414e Patrice Chotard 2022-08-16  603  
b051161f44d414e Patrice Chotard 2022-08-16  604                         
transfer = list_next_entry(transfer, transfer_list);
b051161f44d414e Patrice Chotard 2022-08-16  605                 }
b051161f44d414e Patrice Chotard 2022-08-16  606  
b051161f44d414e Patrice Chotard 2022-08-16  607                 op.data.nbytes 
= transfer->len;
b051161f44d414e Patrice Chotard 2022-08-16  608  
b051161f44d414e Patrice Chotard 2022-08-16  609                 if 
(transfer->rx_buf) {
b051161f44d414e Patrice Chotard 2022-08-16  610                         
qspi->fmode = CCR_FMODE_INDR;
b051161f44d414e Patrice Chotard 2022-08-16  611                         
op.data.buswidth = transfer->rx_nbits;
b051161f44d414e Patrice Chotard 2022-08-16  612                         
op.data.dir = SPI_MEM_DATA_IN;
b051161f44d414e Patrice Chotard 2022-08-16  613                         
op.data.buf.in = transfer->rx_buf;
b051161f44d414e Patrice Chotard 2022-08-16  614                 } else {
b051161f44d414e Patrice Chotard 2022-08-16  615                         
qspi->fmode = CCR_FMODE_INDW;
b051161f44d414e Patrice Chotard 2022-08-16  616                         
op.data.buswidth = transfer->tx_nbits;
b051161f44d414e Patrice Chotard 2022-08-16  617                         
op.data.dir = SPI_MEM_DATA_OUT;
b051161f44d414e Patrice Chotard 2022-08-16  618                         
op.data.buf.out = transfer->tx_buf;
b051161f44d414e Patrice Chotard 2022-08-16  619                 }
b051161f44d414e Patrice Chotard 2022-08-16  620  
b051161f44d414e Patrice Chotard 2022-08-16  621                 ret = 
stm32_qspi_send(spi, &op);
b051161f44d414e Patrice Chotard 2022-08-16  622                 if (ret)
b051161f44d414e Patrice Chotard 2022-08-16  623                         goto 
end_of_transfer;
b051161f44d414e Patrice Chotard 2022-08-16  624  
b051161f44d414e Patrice Chotard 2022-08-16  625                 
msg->actual_length += transfer->len + dummy_bytes;
b051161f44d414e Patrice Chotard 2022-08-16  626         }
b051161f44d414e Patrice Chotard 2022-08-16  627  
b051161f44d414e Patrice Chotard 2022-08-16  628  end_of_transfer:
b051161f44d414e Patrice Chotard 2022-08-16  629         
gpiod_set_value_cansleep(spi->cs_gpiod, false);
b051161f44d414e Patrice Chotard 2022-08-16  630  
b051161f44d414e Patrice Chotard 2022-08-16  631         
mutex_unlock(&qspi->lock);
b051161f44d414e Patrice Chotard 2022-08-16  632  
b051161f44d414e Patrice Chotard 2022-08-16 @633         msg->status = ret;
b051161f44d414e Patrice Chotard 2022-08-16  634         
spi_finalize_current_message(ctrl);
b051161f44d414e Patrice Chotard 2022-08-16  635  
b051161f44d414e Patrice Chotard 2022-08-16  636         return ret;
b051161f44d414e Patrice Chotard 2022-08-16  637  }
b051161f44d414e Patrice Chotard 2022-08-16  638  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to