From patchwork Sun Apr 26 08:16:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 6275401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A5E79F313 for ; Sun, 26 Apr 2015 08:32:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D945620395 for ; Sun, 26 Apr 2015 08:32:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF7A92038F for ; Sun, 26 Apr 2015 08:32:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YmHwB-0002bH-84; Sun, 26 Apr 2015 08:29:15 +0000 Received: from guitar.tcltek.co.il ([192.115.133.116] helo=mx.tkos.co.il) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YmHw6-0002Y1-Mr; Sun, 26 Apr 2015 08:29:11 +0000 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPSA id 5CAFF440868; Sun, 26 Apr 2015 11:28:49 +0300 (IDT) From: Baruch Siach To: David Woodhouse , Brian Norris Subject: [PATCH 3/4] mtd: mxc_nand: fix truncate of unaligned oob copying Date: Sun, 26 Apr 2015 11:16:50 +0300 Message-Id: <1f8e85fd8e75170e1005473c075942cb3d4479fe.1430034929.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150426_012910_995779_C4D0B3B8 X-CRM114-Status: GOOD ( 10.98 ) X-Spam-Score: 0.0 (/) Cc: Baruch Siach , linux-mtd@lists.infradead.org, Sascha Hauer , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Copy to/from oob io area might not be aligned to 4 bytes. When 8 bit ECC is used, the buffer size is 26. Make sure we pass 4 bytes aligned buffer size to memcpy32_{to,from}io to avoid truncating the buffer. Signed-off-by: Baruch Siach --- drivers/mtd/nand/mxc_nand.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index c650f0950b20..c05f5e8fef17 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -840,22 +840,22 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom) for (i = 0; i < num_chunks - 1; i++) memcpy32_fromio(d + i * oob_chunk_size, s + i * sparebuf_size, - oob_chunk_size); + ALIGN(oob_chunk_size, 4)); /* the last chunk */ memcpy32_fromio(d + i * oob_chunk_size, s + i * sparebuf_size, - used_oobsize - i * oob_chunk_size); + ALIGN(used_oobsize - i * oob_chunk_size, 4)); } else { for (i = 0; i < num_chunks - 1; i++) memcpy32_toio(&s[i * sparebuf_size], &d[i * oob_chunk_size], - oob_chunk_size); + ALIGN(oob_chunk_size, 4)); /* the last chunk */ memcpy32_toio(&s[oob_chunk_size * sparebuf_size], &d[i * oob_chunk_size], - used_oobsize - i * oob_chunk_size); + ALIGN(used_oobsize - i * oob_chunk_size, 4)); } }