The patch titled nftl: fix offset alignments has been added to the -mm tree. Its filename is nftl-fix-offset-alignments.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: nftl: fix offset alignments From: dimitri.gorokhovik@xxxxxxx Return-Path: <dimitri.gorokhovik@xxxxxxx> X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on y.localdomain X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham version=3.2.4 Received: from y.localdomain (y.localdomain [127.0.0.1]) by y.localdomain (8.14.2/8.14.2) with ESMTP id n7KLGOeb024890 for <akpm@localhost>; Thu, 20 Aug 2009 14:16:25 -0700 Received: from imap1.linux-foundation.org [140.211.169.55] by y.localdomain with POP3 (fetchmail-6.3.8) for <akpm@localhost> (single-drop); Thu, 20 Aug 2009 14:16:25 -0700 (PDT) Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n7KLENDv026441 for <akpm@xxxxxxxxxxxxxxxxxxxxxxxxxx>; Thu, 20 Aug 2009 14:14:23 -0700 Received: from wmproxy1-g27.free.fr (wmproxy1-g27.free.fr [212.27.42.91]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n7KLDkPS021661 for <akpm@xxxxxxxxxxxxxxxxxxxx>; Thu, 20 Aug 2009 14:13:48 -0700 Received: from wmproxy1-g27.free.fr (localhost [127.0.0.1]) by wmproxy1-g27.free.fr (Postfix) with ESMTP id ADA7B2E7C; Thu, 20 Aug 2009 23:13:45 +0200 (CEST) Received: from zimbra3-e1.priv.proxad.net (zimbra3-e1.priv.proxad.net [172.20.243.153]) by wmproxy1-g27.free.fr (Postfix) with ESMTP id 986B52BCE; Thu, 20 Aug 2009 23:13:45 +0200 (CEST) Date: Thu, 20 Aug 2009 23:13:46 +0200 (CEST) To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: David Woodhouse <dwmw2@xxxxxxxxxxxxx>, David Woodhouse <David.Woodhouse@xxxxxxxxx>, Tim Gardner <tim.gardner@xxxxxxxxxxxxx>, Scott James Remnant <scott@xxxxxxxxxxxxx>, Julia Lawall <julia@xxxxxxx>, David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>, linux-mtd@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx Message-ID: <420676341.3665461250802826403.JavaMail.root@xxxxxxxxxxxxxxxxxxxxxxxxxx> In-Reply-To: <20090819163426.fa90cf9f.akpm@xxxxxxxxxxxxxxxxxxxx> Subject: Re: [PATCH] nftl: fix offset alignments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Originating-IP: [79.85.212.132] X-Mailer: Zimbra 5.0 (ZimbraWebClient - [unknown] (Linux)/5.0.15_GA_2815.UBUNTU8_64) X-Authenticated-User: dimitri.gorokhovik@xxxxxxx X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: none (domain of dimitri.gorokhovik@xxxxxxx does not designate permitted sender hosts) X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by imap1.linux-foundation.org id n7KLENDv026441 "Andrew Morton" <akpm@xxxxxxxxxxxxxxxxxxxx> a écrit : > On Wed, 19 Aug 2009 00:06:28 +0200 (CEST) dimitri.gorokhovik@xxxxxxx > wrote: > ... > > + typeof(offs) mask = mtd->writesize - 1; > > I see no reason to use typeof here. Plain old > > loff_t mask = mtd->writesize - 1; > > would be more conventional. I use typeoff in this way to guard masking code against absent-minded modifications. Attached is a corrected version as suggested. Maybe Julia can come up with a clever rule for detecting unusual masking operations automatically :-) ? --- Subject: nftl: fix offset alignments Arithmetic conversion in the mask computation makes the upper word of the second argument passed down to mtd->read_oob(), be always 0 (assuming 'offs' being a 64-bit signed long long type, and 'mtd->writesize' being a 32-bit unsigned int type). This patch applies over the other one adding masking in nftl_write, "nftl: write support is broken". Signed-off-by: Dimitri Gorokhovik <dimitri.gorokhovik@xxxxxxx> Cc: David Woodhouse <dwmw2@xxxxxxxxxxxxx> Cc: Tim Gardner <tim.gardner@xxxxxxxxxxxxx> Cc: Scott James Remnant <scott@xxxxxxxxxxxxx> --- drivers/mtd/nftlcore.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index 665d3eb..1002e18 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c @@ -135,16 +135,17 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev) int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, size_t *retlen, uint8_t *buf) { + loff_t mask = mtd->writesize - 1; struct mtd_oob_ops ops; int res; ops.mode = MTD_OOB_PLACE; - ops.ooboffs = offs & (mtd->writesize - 1); + ops.ooboffs = offs & mask; ops.ooblen = len; ops.oobbuf = buf; ops.datbuf = NULL; - res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); + res = mtd->read_oob(mtd, offs & ~mask, &ops); *retlen = ops.oobretlen; return res; } @@ -155,16 +156,17 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, size_t *retlen, uint8_t *buf) { + loff_t mask = mtd->writesize - 1; struct mtd_oob_ops ops; int res; ops.mode = MTD_OOB_PLACE; - ops.ooboffs = offs & (mtd->writesize - 1); + ops.ooboffs = offs & mask; ops.ooblen = len; ops.oobbuf = buf; ops.datbuf = NULL; - res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); + res = mtd->write_oob(mtd, offs & ~mask, &ops); *retlen = ops.oobretlen; return res; } @@ -177,17 +179,18 @@ int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len, size_t *retlen, uint8_t *buf, uint8_t *oob) { + loff_t mask = mtd->writesize - 1; struct mtd_oob_ops ops; int res; ops.mode = MTD_OOB_PLACE; - ops.ooboffs = offs & (mtd->writesize - 1); + ops.ooboffs = offs & mask; ops.ooblen = mtd->oobsize; ops.oobbuf = oob; ops.datbuf = buf; ops.len = len; - res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); + res = mtd->write_oob(mtd, offs & ~mask, &ops); *retlen = ops.retlen; return res; } -- 1.6.3.3 Patches currently in -mm which might be from dimitri.gorokhovik@xxxxxxx are nftl-write-support-is-broken.patch nftl-fix-offset-alignments.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html