diff options
author | Trent Piepho <tpiepho@impinj.com> | 2017-10-26 21:08:39 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-10-31 07:20:23 -0400 |
commit | 974488e4ce1ed0b39f2c711c13f523c5912128a1 (patch) | |
tree | 50cdde5f72aac13d294cfb36d4b7fbfd348581fd | |
parent | 71abd29057cb17b6b9532421821dc443427399ed (diff) |
spi: imx: Fix failure path leak on GPIO request error
If the code that requests any chip select GPIOs fails, the cleanup of
spi_bitbang_start() by calling spi_bitbang_stop() is not done.
Fix this by moving spi_bitbang_start() to after the code that requets
GPIOs. The GPIOs are dev managed and don't need explicit cleanup.
Since spi_bitbang_start() is now the last operation, it doesn't need
to be cleaned up in the failure path.
CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <kernel@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@nxp.com>
CC: Mark Brown <broonie@kernel.org>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-imx.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index fe35aaea323b..5ddd32ba2521 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
@@ -1613,11 +1613,6 @@ static int spi_imx_probe(struct platform_device *pdev) | |||
1613 | spi_imx->devtype_data->intctrl(spi_imx, 0); | 1613 | spi_imx->devtype_data->intctrl(spi_imx, 0); |
1614 | 1614 | ||
1615 | master->dev.of_node = pdev->dev.of_node; | 1615 | master->dev.of_node = pdev->dev.of_node; |
1616 | ret = spi_bitbang_start(&spi_imx->bitbang); | ||
1617 | if (ret) { | ||
1618 | dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); | ||
1619 | goto out_clk_put; | ||
1620 | } | ||
1621 | 1616 | ||
1622 | if (!spi_imx->slave_mode) { | 1617 | if (!spi_imx->slave_mode) { |
1623 | if (!master->cs_gpios) { | 1618 | if (!master->cs_gpios) { |
@@ -1641,6 +1636,12 @@ static int spi_imx_probe(struct platform_device *pdev) | |||
1641 | } | 1636 | } |
1642 | } | 1637 | } |
1643 | 1638 | ||
1639 | ret = spi_bitbang_start(&spi_imx->bitbang); | ||
1640 | if (ret) { | ||
1641 | dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); | ||
1642 | goto out_clk_put; | ||
1643 | } | ||
1644 | |||
1644 | dev_info(&pdev->dev, "probed\n"); | 1645 | dev_info(&pdev->dev, "probed\n"); |
1645 | 1646 | ||
1646 | clk_disable(spi_imx->clk_ipg); | 1647 | clk_disable(spi_imx->clk_ipg); |