Messages in this thread | | | Date | Tue, 31 May 2022 10:22:20 +0300 | From | Dan Carpenter <> | Subject | drivers/i2c/busses/i2c-qcom-geni.c:626 geni_i2c_gpi_xfer() error: uninitialized symbol 'rx_addr'. |
| |
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 8ab2afa23bd197df47819a87f0265c0ac95c5b6a commit: d8703554f4dea9775417525b22b3d65ed1c6b16e i2c: qcom-geni: Add support for GPI DMA config: arm64-randconfig-m031-20220530 (https://download.01.org/0day-ci/archive/20220531/202205310736.Oh37uaNh-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings: drivers/i2c/busses/i2c-qcom-geni.c:626 geni_i2c_gpi_xfer() error: uninitialized symbol 'rx_addr'. drivers/i2c/busses/i2c-qcom-geni.c:635 geni_i2c_gpi_xfer() error: uninitialized symbol 'tx_addr'.
vim +/rx_addr +626 drivers/i2c/busses/i2c-qcom-geni.c
d8703554f4dea9 Vinod Koul 2022-02-21 566 static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], int num) d8703554f4dea9 Vinod Koul 2022-02-21 567 { d8703554f4dea9 Vinod Koul 2022-02-21 568 struct dma_slave_config config = {}; d8703554f4dea9 Vinod Koul 2022-02-21 569 struct gpi_i2c_config peripheral = {}; d8703554f4dea9 Vinod Koul 2022-02-21 570 int i, ret = 0, timeout; d8703554f4dea9 Vinod Koul 2022-02-21 571 dma_addr_t tx_addr, rx_addr; d8703554f4dea9 Vinod Koul 2022-02-21 572 void *tx_buf = NULL, *rx_buf = NULL; d8703554f4dea9 Vinod Koul 2022-02-21 573 const struct geni_i2c_clk_fld *itr = gi2c->clk_fld; d8703554f4dea9 Vinod Koul 2022-02-21 574 d8703554f4dea9 Vinod Koul 2022-02-21 575 config.peripheral_config = &peripheral; d8703554f4dea9 Vinod Koul 2022-02-21 576 config.peripheral_size = sizeof(peripheral); d8703554f4dea9 Vinod Koul 2022-02-21 577 d8703554f4dea9 Vinod Koul 2022-02-21 578 peripheral.pack_enable = I2C_PACK_TX | I2C_PACK_RX; d8703554f4dea9 Vinod Koul 2022-02-21 579 peripheral.cycle_count = itr->t_cycle_cnt; d8703554f4dea9 Vinod Koul 2022-02-21 580 peripheral.high_count = itr->t_high_cnt; d8703554f4dea9 Vinod Koul 2022-02-21 581 peripheral.low_count = itr->t_low_cnt; d8703554f4dea9 Vinod Koul 2022-02-21 582 peripheral.clk_div = itr->clk_div; d8703554f4dea9 Vinod Koul 2022-02-21 583 peripheral.set_config = 1; d8703554f4dea9 Vinod Koul 2022-02-21 584 peripheral.multi_msg = false; d8703554f4dea9 Vinod Koul 2022-02-21 585 d8703554f4dea9 Vinod Koul 2022-02-21 586 for (i = 0; i < num; i++) { d8703554f4dea9 Vinod Koul 2022-02-21 587 gi2c->cur = &msgs[i]; d8703554f4dea9 Vinod Koul 2022-02-21 588 gi2c->err = 0; d8703554f4dea9 Vinod Koul 2022-02-21 589 dev_dbg(gi2c->se.dev, "msg[%d].len:%d\n", i, gi2c->cur->len); d8703554f4dea9 Vinod Koul 2022-02-21 590 d8703554f4dea9 Vinod Koul 2022-02-21 591 peripheral.stretch = 0; d8703554f4dea9 Vinod Koul 2022-02-21 592 if (i < num - 1) d8703554f4dea9 Vinod Koul 2022-02-21 593 peripheral.stretch = 1; d8703554f4dea9 Vinod Koul 2022-02-21 594 d8703554f4dea9 Vinod Koul 2022-02-21 595 peripheral.addr = msgs[i].addr; d8703554f4dea9 Vinod Koul 2022-02-21 596 d8703554f4dea9 Vinod Koul 2022-02-21 597 if (msgs[i].flags & I2C_M_RD) { d8703554f4dea9 Vinod Koul 2022-02-21 598 ret = geni_i2c_gpi(gi2c, &msgs[i], &config, d8703554f4dea9 Vinod Koul 2022-02-21 599 &rx_addr, &rx_buf, I2C_READ, gi2c->rx_c);
I feel like the "rx_buf" pointer needs to be set to NULL on each iteration through the loop. Otherwise we use the previous rx_bug for the next msg[i].
d8703554f4dea9 Vinod Koul 2022-02-21 600 if (ret) d8703554f4dea9 Vinod Koul 2022-02-21 601 goto err; d8703554f4dea9 Vinod Koul 2022-02-21 602 } d8703554f4dea9 Vinod Koul 2022-02-21 603 d8703554f4dea9 Vinod Koul 2022-02-21 604 ret = geni_i2c_gpi(gi2c, &msgs[i], &config, d8703554f4dea9 Vinod Koul 2022-02-21 605 &tx_addr, &tx_buf, I2C_WRITE, gi2c->tx_c); d8703554f4dea9 Vinod Koul 2022-02-21 606 if (ret) d8703554f4dea9 Vinod Koul 2022-02-21 607 goto err; d8703554f4dea9 Vinod Koul 2022-02-21 608 d8703554f4dea9 Vinod Koul 2022-02-21 609 if (msgs[i].flags & I2C_M_RD) d8703554f4dea9 Vinod Koul 2022-02-21 610 dma_async_issue_pending(gi2c->rx_c); d8703554f4dea9 Vinod Koul 2022-02-21 611 dma_async_issue_pending(gi2c->tx_c); d8703554f4dea9 Vinod Koul 2022-02-21 612 d8703554f4dea9 Vinod Koul 2022-02-21 613 timeout = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT); d8703554f4dea9 Vinod Koul 2022-02-21 614 if (!timeout) { d8703554f4dea9 Vinod Koul 2022-02-21 615 dev_err(gi2c->se.dev, "I2C timeout gpi flags:%d addr:0x%x\n", d8703554f4dea9 Vinod Koul 2022-02-21 616 gi2c->cur->flags, gi2c->cur->addr); d8703554f4dea9 Vinod Koul 2022-02-21 617 gi2c->err = -ETIMEDOUT; d8703554f4dea9 Vinod Koul 2022-02-21 618 goto err; d8703554f4dea9 Vinod Koul 2022-02-21 619 } d8703554f4dea9 Vinod Koul 2022-02-21 620 d8703554f4dea9 Vinod Koul 2022-02-21 621 if (gi2c->err) { d8703554f4dea9 Vinod Koul 2022-02-21 622 ret = gi2c->err; d8703554f4dea9 Vinod Koul 2022-02-21 623 goto err; d8703554f4dea9 Vinod Koul 2022-02-21 624 } d8703554f4dea9 Vinod Koul 2022-02-21 625 d8703554f4dea9 Vinod Koul 2022-02-21 @626 geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); ^^^^^^^ Uninitialized variables
d8703554f4dea9 Vinod Koul 2022-02-21 627 } d8703554f4dea9 Vinod Koul 2022-02-21 628 d8703554f4dea9 Vinod Koul 2022-02-21 629 return num; d8703554f4dea9 Vinod Koul 2022-02-21 630 d8703554f4dea9 Vinod Koul 2022-02-21 631 err: d8703554f4dea9 Vinod Koul 2022-02-21 632 dev_err(gi2c->se.dev, "GPI transfer failed: %d\n", ret); d8703554f4dea9 Vinod Koul 2022-02-21 633 dmaengine_terminate_sync(gi2c->rx_c); d8703554f4dea9 Vinod Koul 2022-02-21 634 dmaengine_terminate_sync(gi2c->tx_c); d8703554f4dea9 Vinod Koul 2022-02-21 @635 geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); ^^^^^^^^^^^^^^^ Using old tx_buf or uninitialized tx_addr.
d8703554f4dea9 Vinod Koul 2022-02-21 636 return ret; d8703554f4dea9 Vinod Koul 2022-02-21 637 }
-- 0-DAY CI Kernel Test Service https://01.org/lkp
| |