From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from tim.rpsys.net ([194.106.48.114]) by pentafluge.infradead.org with esmtps (Exim 4.62 #1 (Red Hat Linux)) id 1GDq6u-00030c-7K for linux-mtd@lists.infradead.org; Thu, 17 Aug 2006 23:13:09 +0100 Subject: Re: 2.6.18-rc4 jffs2 problems From: Richard Purdie To: linux-mtd , Thomas Gleixner In-Reply-To: <1154976111.17725.8.camel@localhost.localdomain> References: <1154976111.17725.8.camel@localhost.localdomain> Content-Type: text/plain Date: Thu, 17 Aug 2006 23:09:47 +0100 Message-Id: <1155852587.5530.30.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: LKML List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Read the return value before we release the nand device otherwise the value can become corrupted by another user of chip->ops, ultimately resulting in filesystem corruption. Signed-off-by: Richard Purdie --- This fixes the jffs2 errors and filesystem corruption I reported. It should be applied for 2.6.18. drivers/mtd/nand/nand_base.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: git/drivers/mtd/nand/nand_base.c =================================================================== --- git.orig/drivers/mtd/nand/nand_base.c 2006-08-17 22:46:19.000000000 +0100 +++ git/drivers/mtd/nand/nand_base.c 2006-08-17 22:47:27.000000000 +0100 @@ -1093,9 +1093,10 @@ static int nand_read(struct mtd_info *mt ret = nand_do_read_ops(mtd, from, &chip->ops); + *retlen = chip->ops.retlen; + nand_release_device(mtd); - *retlen = chip->ops.retlen; return ret; } @@ -1691,9 +1692,10 @@ static int nand_write(struct mtd_info *m ret = nand_do_write_ops(mtd, to, &chip->ops); + *retlen = chip->ops.retlen; + nand_release_device(mtd); - *retlen = chip->ops.retlen; return ret; }