From patchwork Sat Oct 15 03:09:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 119951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B932AB70ED for ; Sat, 15 Oct 2011 14:09:51 +1100 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1REud4-0007ih-Rv; Sat, 15 Oct 2011 03:09:42 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1REud4-0007FV-KV; Sat, 15 Oct 2011 03:09:42 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1REud1-0007Ez-3E for linux-mtd@lists.infradead.org; Sat, 15 Oct 2011 03:09:39 +0000 Received: by iarr31 with SMTP id r31so3959844iar.36 for ; Fri, 14 Oct 2011 20:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=eDaA6fwHC+q7xn/QnMtc57XksC5DC27w3C8G7SL0DRc=; b=nMNI/RnNcQZ58UUrLLSpvw4NIjMg4twm0skp5kDY4zXd/KhoIIl7FZwiSIvLjTiX9d F97WIGswn4PtNsfpvS3+6TW1XMXbLo/imI0PpCkLExiPfBHFI5Dk14Qebzr+nq/XDFAt Ub3tZuswt0o6vakq3o91F45WRXaOenF7He+FU= Received: by 10.68.0.227 with SMTP id 3mr20879979pbh.48.1318648176549; Fri, 14 Oct 2011 20:09:36 -0700 (PDT) Received: from localhost.localdomain (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPS id w4sm29427528pbf.6.2011.10.14.20.09.34 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Oct 2011 20:09:35 -0700 (PDT) From: Brian Norris To: Artem Bityutskiy Subject: [PATCH] mtd: nand: initialize ops.mode Date: Fri, 14 Oct 2011 20:09:33 -0700 Message-Id: <1318648173-17775-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.5.4 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20111014_230939_248362_75F63E46 X-CRM114-Status: GOOD ( 12.89 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Kevin Cernekee , Brian Norris , linux-mtd@lists.infradead.org, David Woodhouse 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 Our `ops' information was converted to a local variable recently, and apparently, old code relied on the fact that the global version was often left in a valid mode. We can't make this assumption on local structs, and we shouldn't be relying on a previous state anyway. Instead, we initialize mode to 0 for don't-care situations (i.e., the operation does not use OOB anyway) and MTD_OPS_PLACE_OOB when we want to place OOB data. This fixes a bug with nand_default_block_markbad(), where we catch on the BUG() call in nand_fill_oob(): Kernel bug detected[#1]: ... Call Trace: [<80307350>] nand_fill_oob.clone.5+0xa4/0x15c [<803075d8>] nand_do_write_oob+0x1d0/0x260 [<803077c4>] nand_default_block_markbad+0x15c/0x1a8 [<802e8c2c>] part_block_markbad+0x80/0x98 [<802ebc74>] mtd_ioctl+0x6d8/0xbd0 [<802ec1a4>] mtd_unlocked_ioctl+0x38/0x5c [<800d9c60>] do_vfs_ioctl+0xa4/0x6e4 [<800da2e4>] sys_ioctl+0x44/0xa0 [<8001381c>] stack_done+0x20/0x40 Signed-off-by: Brian Norris --- drivers/mtd/nand/nand_base.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 51653d9..3ed9c5e 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -420,6 +420,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) ops.datbuf = NULL; ops.oobbuf = buf; ops.ooboffs = chip->badblockpos & ~0x01; + ops.mode = MTD_OPS_PLACE_OOB; do { ret = nand_do_write_oob(mtd, ofs, &ops); @@ -1596,6 +1597,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, ops.len = len; ops.datbuf = buf; ops.oobbuf = NULL; + ops.mode = 0; ret = nand_do_read_ops(mtd, from, &ops); @@ -2306,6 +2308,7 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, ops.len = len; ops.datbuf = (uint8_t *)buf; ops.oobbuf = NULL; + ops.mode = 0; ret = nand_do_write_ops(mtd, to, &ops); @@ -2341,6 +2344,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, ops.len = len; ops.datbuf = (uint8_t *)buf; ops.oobbuf = NULL; + ops.mode = 0; ret = nand_do_write_ops(mtd, to, &ops);