[bug report] spi: lpspi: Let watermark change with send data length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Clark Wang,

This is a semi-automatic email about new static checker warnings.

The patch cf86874bb9bd: "spi: lpspi: Let watermark change with send
data length" from Dec 7, 2018, leads to the following Smatch
complaint:

    drivers/spi/spi-fsl-lpspi.c:322 fsl_lpspi_setup_transfer()
    error: we previously assumed 't' could be null (see line 302)

drivers/spi/spi-fsl-lpspi.c
   301		fsl_lpspi->config.bpw = t ? t->bits_per_word : spi->bits_per_word;
                                       ^^^

   302		fsl_lpspi->config.speed_hz = t ? t->speed_hz : spi->max_speed_hz;
                                            ^^^
Old code checks for NULL.

   303		fsl_lpspi->config.chip_select = spi->chip_select;
   304	
   305		if (!fsl_lpspi->config.speed_hz)
   306			fsl_lpspi->config.speed_hz = spi->max_speed_hz;
   307		if (!fsl_lpspi->config.bpw)
   308			fsl_lpspi->config.bpw = spi->bits_per_word;
   309	
   310		/* Initialize the functions for transfer */
   311		if (fsl_lpspi->config.bpw <= 8) {
   312			fsl_lpspi->rx = fsl_lpspi_buf_rx_u8;
   313			fsl_lpspi->tx = fsl_lpspi_buf_tx_u8;
   314		} else if (fsl_lpspi->config.bpw <= 16) {
   315			fsl_lpspi->rx = fsl_lpspi_buf_rx_u16;
   316			fsl_lpspi->tx = fsl_lpspi_buf_tx_u16;
   317		} else {
   318			fsl_lpspi->rx = fsl_lpspi_buf_rx_u32;
   319			fsl_lpspi->tx = fsl_lpspi_buf_tx_u32;
   320		}
   321	
   322		if (t->len <= fsl_lpspi->txfifosize)
                    ^^^^^^
   323			fsl_lpspi->watermark = t->len;
                                               ^^^^^^
The patch adds new unchecked dereferences.

   324		else

regards,
dan carpenter



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux