Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e774943 authored by Scott Ellis's avatar Scott Ellis Committed by Grant Likely
Browse files

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: default avatarScott Ellis <scott@jumpnowtek.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 07081fd8
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -751,11 +751,13 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
	mcspi = spi_master_get_devdata(spi->master);
	mcspi = spi_master_get_devdata(spi->master);
	mcspi_dma = &mcspi->dma_channels[spi->chip_select];
	mcspi_dma = &mcspi->dma_channels[spi->chip_select];


	if (spi->controller_state) {
		/* Unlink controller state from context save list */
		/* Unlink controller state from context save list */
		cs = spi->controller_state;
		cs = spi->controller_state;
		list_del(&cs->node);
		list_del(&cs->node);


		kfree(spi->controller_state);
		kfree(spi->controller_state);
	}


	if (mcspi_dma->dma_rx_channel != -1) {
	if (mcspi_dma->dma_rx_channel != -1) {
		omap_free_dma(mcspi_dma->dma_rx_channel);
		omap_free_dma(mcspi_dma->dma_rx_channel);