summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-imx.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2016-09-26 14:14:53 +0200
committerMark Brown <broonie@kernel.org>2016-09-26 18:08:46 +0200
commitf13d4e189d209af0f552e9900acd06ee4a35e601 (patch)
treefd296df6645eb783150cac054f698331504a6980 /drivers/spi/spi-imx.c
parentspi: imx: support loopback mode on imx35 (diff)
downloadlinux-f13d4e189d209af0f552e9900acd06ee4a35e601.tar.xz
linux-f13d4e189d209af0f552e9900acd06ee4a35e601.zip
spi: imx: Gracefully handle NULL master->cs_gpios
It is possible that master->cs_gpios is NULL after spi_bitbang_start(), this happens if the master has no CS GPIOs specified in DT. Check for this case after spi_bitbang_start() to prevent NULL pointer dereference in the subsequent for loop, which accesses the master->cs_gpios field. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Martin Kaiser <martin@kaiser.cx> Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-imx.c')
-rw-r--r--drivers/spi/spi-imx.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 53e7a326c213..1ef5429afcb6 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1268,6 +1268,11 @@ static int spi_imx_probe(struct platform_device *pdev)
goto out_clk_put;
}
+ if (!master->cs_gpios) {
+ dev_err(&pdev->dev, "No CS GPIOs available\n");
+ goto out_clk_put;
+ }
+
for (i = 0; i < master->num_chipselect; i++) {
if (!gpio_is_valid(master->cs_gpios[i]))
continue;