Skip to content

Commit

Permalink
spi: imx: Gracefully handle NULL master->cs_gpios
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marek Vasut authored and Mark Brown committed Sep 26, 2016
1 parent 15ca921 commit f13d4e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/spi/spi-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f13d4e1

Please sign in to comment.