diff options
author | Scott Ellis <scott@jumpnowtek.com> | 2010-03-10 16:22:45 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-03-10 16:22:45 -0500 |
commit | 5e7749436d576a525d7b2a4bcffb17b3364b9e00 (patch) | |
tree | 1c7e0c67f0e5cdc49f594afd65204d09a3a8a017 /drivers/spi/omap2_mcspi.c | |
parent | 07081fd8587478849b69d7b41596e81ff5a7f532 (diff) |
spi/omap2_mcspi: fix NULL pointer dereference
Check spi->controller_state before dereferencing.
Shows up NULL here when using spi_alloc_device()/spi_add_device()
and spi_add_device() fails before spi_setup(). Calling spi_dev_put()
on the leftover spi_device results in the error.
Signed-off-by: Scott Ellis <scott@jumpnowtek.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/omap2_mcspi.c')
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 715c518b1b68..87d44eeaaa7b 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
@@ -751,11 +751,13 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) | |||
751 | mcspi = spi_master_get_devdata(spi->master); | 751 | mcspi = spi_master_get_devdata(spi->master); |
752 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 752 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
753 | 753 | ||
754 | /* Unlink controller state from context save list */ | 754 | if (spi->controller_state) { |
755 | cs = spi->controller_state; | 755 | /* Unlink controller state from context save list */ |
756 | list_del(&cs->node); | 756 | cs = spi->controller_state; |
757 | list_del(&cs->node); | ||
757 | 758 | ||
758 | kfree(spi->controller_state); | 759 | kfree(spi->controller_state); |
760 | } | ||
759 | 761 | ||
760 | if (mcspi_dma->dma_rx_channel != -1) { | 762 | if (mcspi_dma->dma_rx_channel != -1) { |
761 | omap_free_dma(mcspi_dma->dma_rx_channel); | 763 | omap_free_dma(mcspi_dma->dma_rx_channel); |