From patchwork Thu Sep 16 07:05:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 64943 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id AB0CA1DDE0 for ; Thu, 16 Sep 2010 17:05:46 +1000 (EST) Received: from mailhub1.si.c-s.fr (pegase1.c-s.fr [194.2.40.7]) by ozlabs.org (Postfix) with ESMTP id 2517CB70CC for ; Thu, 16 Sep 2010 17:05:38 +1000 (EST) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 98AC91C80A8; Thu, 16 Sep 2010 09:05:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1FF0lJbed0br; Thu, 16 Sep 2010 09:05:36 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 80E6B1C8122; Thu, 16 Sep 2010 09:05:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 54409C73CA; Thu, 16 Sep 2010 09:05:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id UbzdZnp0DkiH; Thu, 16 Sep 2010 09:05:36 +0200 (CEST) Received: from unknown (unknown [172.25.231.36]) by messagerie.si.c-s.fr (Postfix) with SMTP id 4882CC7391; Thu, 16 Sep 2010 09:05:25 +0200 (CEST) Subject: [PATCH] spi_mpc8xxx: fix buffer overrun when sending only/receiving only more than PAGE_SIZE bytes From: christophe leroy To: David Brownell , Grant Likely , spi-devel-general@lists.sourceforge.net, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Message-Id: <20100916070525.4882CC7391@messagerie.si.c-s.fr> Date: Thu, 16 Sep 2010 09:05:25 +0200 (CEST) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org This patch applies to 2.6.34.7 and 2.6.35.4 It fixes an issue when sending only or receiving only more than PAGE_SIZE bytes Signed-off-by: christophe leroy Acked-by: Joakim Tjernlund diff -urN c/drivers/spi/spi_mpc8xxx.c d/drivers/spi/spi_mpc8xxx.c --- c/drivers/spi/spi_mpc8xxx.c 2010-09-08 16:44:03.000000000 +0200 +++ d/drivers/spi/spi_mpc8xxx.c 2010-09-08 16:44:14.000000000 +0200 @@ -393,11 +393,17 @@ xfer_ofs = mspi->xfer_in_progress->len - mspi->count; - out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs); + if (mspi->rx_dma == mspi->dma_dummy_rx) + out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma); + else + out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs); out_be16(&rx_bd->cbd_datlen, 0); out_be16(&rx_bd->cbd_sc, BD_SC_EMPTY | BD_SC_INTRPT | BD_SC_WRAP); - out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs); + if (mspi->tx_dma == mspi->dma_dummy_tx) + out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma); + else + out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs); out_be16(&tx_bd->cbd_datlen, xfer_len); out_be16(&tx_bd->cbd_sc, BD_SC_READY | BD_SC_INTRPT | BD_SC_WRAP | BD_SC_LAST);