From patchwork Thu Feb 3 12:56:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Tereshonkov X-Patchwork-Id: 81640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AD1DCB7127 for ; Fri, 4 Feb 2011 00:03:43 +1100 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PkykZ-00010h-Kr; Thu, 03 Feb 2011 12:57:27 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PkykY-0000EA-6n; Thu, 03 Feb 2011 12:57:26 +0000 Received: from smtp.nokia.com ([147.243.1.47] helo=mgw-sa01.nokia.com) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PkykU-0000Ds-Ub for linux-mtd@lists.infradead.org; Thu, 03 Feb 2011 12:57:24 +0000 Received: from nokia.com (localhost [127.0.0.1]) by mgw-sa01.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p13CvJuj001321; Thu, 3 Feb 2011 14:57:19 +0200 Received: from localhost.localdomain ([esdhcp03995.research.nokia.com [172.21.39.95]]) by mgw-sa01.nokia.com with RELAY id p13CurLh000777 ; Thu, 3 Feb 2011 14:56:54 +0200 From: Roman Tereshonkov To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address Date: Thu, 3 Feb 2011 14:56:51 +0200 Message-Id: <1296737811-22952-1-git-send-email-roman.tereshonkov@nokia.com> X-Mailer: git-send-email 1.7.0.4 X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110203_075723_287304_F26E57F1 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 TVD_RCVD_SPACE_BRACKET TVD_RCVD_SPACE_BRACKET -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: kyungmin.park@samsung.com, Roman Tereshonkov X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In onenand_verify function the address can be writepage non-aligned. When a page is read for comparing the right offset should be used for "this->verify_buf" to get the right matching with compared "buf" buffer. Signed-off-by: Roman Tereshonkov --- drivers/mtd/onenand/onenand_base.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index bac41ca..557a06e 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -1646,11 +1646,10 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, int ret = 0; int thislen, column; + column = addr & (this->writesize - 1); + while (len != 0) { - thislen = min_t(int, this->writesize, len); - column = addr & (this->writesize - 1); - if (column + thislen > this->writesize) - thislen = this->writesize - column; + thislen = min_t(int, this->writesize - column, len); this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); @@ -1662,14 +1661,16 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, onenand_update_bufferram(mtd, addr, 1); - this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize); + this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, + this->writesize); - if (memcmp(buf, this->verify_buf, thislen)) + if (memcmp(buf, this->verify_buf + column, thislen)) return -EBADMSG; len -= thislen; buf += thislen; addr += thislen; + column = 0; } return 0;