diff mbox

[1/1] spi: dw: fix crash on setup stage

Message ID 1427307986-112219-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit 207cda93f0446c2da5461a37252c7468ddc1c2bc
Headers show

Commit Message

Andy Shevchenko March 25, 2015, 6:26 p.m. UTC
The commit 1a7b7ee72c21 (spi: Ensure that CS line is in non-active state after
spi_setup()) introduces an unconditional call of spi_set_cs() before ->setup().
The dw_spi_set_cs() relies on that fact that ->setup() is already called, but
it doesn't now. This patch fixes the crash by adding an additional check to
dw_spi_set_cs().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-dw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown March 25, 2015, 6:54 p.m. UTC | #1
On Wed, Mar 25, 2015 at 08:26:26PM +0200, Andy Shevchenko wrote:
> The commit 1a7b7ee72c21 (spi: Ensure that CS line is in non-active state after
> spi_setup()) introduces an unconditional call of spi_set_cs() before ->setup().
> The dw_spi_set_cs() relies on that fact that ->setup() is already called, but
> it doesn't now. This patch fixes the crash by adding an additional check to
> dw_spi_set_cs().

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index cafac22..8d67d03 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -144,7 +144,7 @@  static void dw_spi_set_cs(struct spi_device *spi, bool enable)
 	struct chip_data *chip = spi_get_ctldata(spi);
 
 	/* Chip select logic is inverted from spi_set_cs() */
-	if (chip->cs_control)
+	if (chip && chip->cs_control)
 		chip->cs_control(!enable);
 
 	if (!enable)