]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
spi: imx: Fix possible NULL pointer deref
authorSascha Hauer <s.hauer@pengutronix.de>
Thu, 17 Mar 2016 08:21:50 +0000 (09:21 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 17 Mar 2016 11:44:34 +0000 (11:44 +0000)
transfer could be NULL in spi_imx_can_dma() when it's called from
spi_imx_setupxfer() with a NULL transfer. Test for a NULL pointer before
dereferencing it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c

index b79d70d6dabfe18086f16ffc69ee2c5879298760..50769078e72e98316f5ea19efd69de536be91a72 100644 (file)
@@ -211,11 +211,15 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
                         struct spi_transfer *transfer)
 {
        struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
-       unsigned int bpw = transfer->bits_per_word;
+       unsigned int bpw;
 
        if (!master->dma_rx)
                return false;
 
+       if (!transfer)
+               return false;
+
+       bpw = transfer->bits_per_word;
        if (!bpw)
                bpw = spi->bits_per_word;