From patchwork Fri Mar 12 15:11:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Ellis X-Patchwork-Id: 85299 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2CFCbSd022127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 12 Mar 2010 15:13:13 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nq6XS-0002zv-PT; Fri, 12 Mar 2010 15:12:34 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nq6XR-0002zl-Mz for spi-devel-general@lists.sourceforge.net; Fri, 12 Mar 2010 15:12:33 +0000 X-ACL-Warn: Received: from pan.gwi.net ([207.5.128.165]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1Nq6XQ-0006yw-Ib for spi-devel-general@lists.sourceforge.net; Fri, 12 Mar 2010 15:12:33 +0000 Received: from [192.168.10.4] (66-63-88-74.static.suscom-maine.net [66.63.88.74]) by pan.gwi.net (8.13.1/8.13.1) with ESMTP id o2CFBsc3031295; Fri, 12 Mar 2010 10:11:54 -0500 (EST) (envelope-from scott@jumpnowtek.com) From: Scott Ellis To: spi-devel-general@lists.sourceforge.net Date: Fri, 12 Mar 2010 10:11:53 -0500 Message-ID: <1268406713.14445.50.camel@quad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. _SUMMARY_ X-Headers-End: 1Nq6XQ-0006yw-Ib Cc: David Brownell , Tony Lindgren , Aaro Koskinen , Kevin Hilman , Andrew Morton , linux-omap@vger.kernel.org, Roman Tereshonkov Subject: [spi-devel-general] [PATCH 1/6 Revised] SPI omap2_mcspi.c: Check params before dereference or use X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 15:13:13 +0000 (UTC) diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 715c518..fe1b56d 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -748,22 +748,26 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) struct omap2_mcspi_dma *mcspi_dma; struct omap2_mcspi_cs *cs; - mcspi = spi_master_get_devdata(spi->master); - mcspi_dma = &mcspi->dma_channels[spi->chip_select]; + if (spi->controller_state) { + /* Unlink controller state from context save list */ + cs = spi->controller_state; + list_del(&cs->node); - /* Unlink controller state from context save list */ - cs = spi->controller_state; - list_del(&cs->node); + kfree(spi->controller_state); + } - kfree(spi->controller_state); + if (spi->chip_select < spi->master->num_chipselect) { + mcspi = spi_master_get_devdata(spi->master); + mcspi_dma = &mcspi->dma_channels[spi->chip_select]; - if (mcspi_dma->dma_rx_channel != -1) { - omap_free_dma(mcspi_dma->dma_rx_channel); - mcspi_dma->dma_rx_channel = -1; - } - if (mcspi_dma->dma_tx_channel != -1) { - omap_free_dma(mcspi_dma->dma_tx_channel); - mcspi_dma->dma_tx_channel = -1; + if (mcspi_dma->dma_rx_channel != -1) { + omap_free_dma(mcspi_dma->dma_rx_channel); + mcspi_dma->dma_rx_channel = -1; + } + if (mcspi_dma->dma_tx_channel != -1) { + omap_free_dma(mcspi_dma->dma_tx_channel); + mcspi_dma->dma_tx_channel = -1; + } } }