linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] omap2_mcspi.c: NULL pointer dereference
@ 2010-02-23 19:36 Scott Ellis
  2010-02-25 11:14 ` Felipe Contreras
  0 siblings, 1 reply; 2+ messages in thread
From: Scott Ellis @ 2010-02-23 19:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Brownell, Andrew Morton, Tony Lindgren, Kevin Hilman,
	Aaro Koskinen, spi-devel-general, gumstix-users

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>

 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 ba1a872..b1f82c1 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)
 	mcspi = spi_master_get_devdata(spi->master);
 	mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	/* Unlink controller state from context save list */
-	cs = spi->controller_state;
-	list_del(&cs->node);
+	if (spi->controller_state) {
+		/* Unlink controller state from context save list */
+		cs = spi->controller_state;
+		list_del(&cs->node);
 
-	kfree(spi->controller_state);
+		kfree(spi->controller_state);
+	}
 
 	if (mcspi_dma->dma_rx_channel != -1) {
 		omap_free_dma(mcspi_dma->dma_rx_channel);



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] omap2_mcspi.c: NULL pointer dereference
  2010-02-23 19:36 [PATCH] omap2_mcspi.c: NULL pointer dereference Scott Ellis
@ 2010-02-25 11:14 ` Felipe Contreras
  0 siblings, 0 replies; 2+ messages in thread
From: Felipe Contreras @ 2010-02-25 11:14 UTC (permalink / raw)
  To: Scott Ellis
  Cc: linux-kernel, David Brownell, Andrew Morton, Tony Lindgren,
	Kevin Hilman, Aaro Koskinen, spi-devel-general, gumstix-users

On Tue, Feb 23, 2010 at 9:36 PM, Scott Ellis <scott@jumpnowtek.com> wrote:
> 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.

This should go to the linux-omap mailing list.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-25 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-23 19:36 [PATCH] omap2_mcspi.c: NULL pointer dereference Scott Ellis
2010-02-25 11:14 ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).