Skip to contentSkip to conversation

dmaengine: check device and channel list for empty

bug report [email protected] 1 participant 1 message Jul 9, 2020 dmaengine

lore
Share & tools
lore
#0 lore raw

Hello Dave Jiang,

The patch deb9541f5052: "dmaengine: check device and channel list for empty" from Jun 26, 2020, leads to the following static checker warnings:

drivers/mmc/host/omap_hsmmc.c:1959 omap_hsmmc_probe() warn: 'host->rx_chan' can also be NULL drivers/mmc/host/omap_hsmmc.c:1959 omap_hsmmc_probe() warn: 'host->tx_chan' can also be NULL drivers/media/platform/xilinx/xilinx-dma.c:736 xvip_dma_init() warn: 'dma->dma' can also be NULL drivers/spi/spi-fsl-dspi.c:520 dspi_request_dma() warn: 'dma->chan_tx' can also be NULL drivers/spi/spi-fsl-dspi.c:528 dspi_request_dma() warn: 'dma->chan_rx' can also be NULL drivers/iio/adc/ti_am335x_adc.c:565 tiadc_request_dma() warn: 'dma->chan' can also be NULL drivers/iio/adc/stm32-dfsdm-adc.c:1381 stm32_dfsdm_dma_request() warn: 'adc->dma_chan' can also be NULL drivers/iio/adc/stm32-adc.c:1837 stm32_adc_dma_request() warn: 'adc->dma_chan' can also be NULL drivers/iio/adc/at91-sama5d2_adc.c:1520 at91_adc_dma_init() warn: 'st->dma_st.dma_chan' can also be NULL sound/soc/ti/davinci-mcasp.c:1902 davinci_mcasp_get_dma_type() warn: 'chan' can also be NULL

drivers/mmc/host/omap_hsmmc.c
1937

  1938          host->rx_chan = dma_request_chan(&pdev->dev, "rx");
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The dma_request_chan() function used to only return error pointers or a valid pointer. We need to update the comments at the start of the function to explain about the new NULL return.

1939 if (IS_ERR(host->rx_chan)) {

  1940                  dev_err(mmc_dev(host->mmc), "RX DMA channel request failed\n");
  1941                  ret = PTR_ERR(host->rx_chan);
  1942                  goto err_irq;
  1943          }
  1944  
  1945          host->tx_chan = dma_request_chan(&pdev->dev, "tx");
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1946          if (IS_ERR(host->tx_chan)) {
  1947                  dev_err(mmc_dev(host->mmc), "TX DMA channel request failed\n");
  1948                  ret = PTR_ERR(host->tx_chan);
  1949                  goto err_irq;
  1950          }
  1951  
  1952          /*
  1953           * Limit the maximum segment size to the lower of the request size
  1954           * and the DMA engine device segment size limits.  In reality, with
  1955           * 32-bit transfers, the DMA engine can do longer segments than this
  1956           * but there is no way to represent that in the DMA model - if we
  1957           * increase this figure here, we get warnings from the DMA API debug.
  1958           */
  1959          mmc->max_seg_size = min3(mmc->max_req_size,
  1960                          dma_get_max_seg_size(host->rx_chan->device->dev),
                                                     ^^^^^^^^^^^^^^^

This will Oops.

  1961                          dma_get_max_seg_size(host->tx_chan->device->dev));
  1962  
  1963          /* Request IRQ for MMC operations */
  1964          ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
  1965                          mmc_hostname(mmc), host);
  1966          if (ret) {
  1967                  dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");

regards,
dan carpenter