From patchwork Tue Jul 3 13:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 10504111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C2361601D3 for ; Tue, 3 Jul 2018 13:34:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B363728B20 for ; Tue, 3 Jul 2018 13:34:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1DBD28B57; Tue, 3 Jul 2018 13:34:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EAB428B55 for ; Tue, 3 Jul 2018 13:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbeGCNeT (ORCPT ); Tue, 3 Jul 2018 09:34:19 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59574 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752494AbeGCNeS (ORCPT ); Tue, 3 Jul 2018 09:34:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0317F6063F; Tue, 3 Jul 2018 13:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530624858; bh=dAwH33eotjnlVsOht7d9rhAgXOscZtW9W2LYyToDBO4=; h=From:To:Cc:Subject:Date:From; b=JD7kCBmgW6lTorphfMTlbpfFSE99xYAjazAlXlcPwfbFmRp/h3FBtCGdXq0U+2V18 lPCMTjPboc/WXtp4N3payiVtkIbRt6hVvgimEuFdalinsKkKf5FDJs633G2huxc/HK dibz86UG4TAvtf3TkcgV6YoqBu3jtPSCGQI68/Fc= Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B4791605A4; Tue, 3 Jul 2018 13:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530624857; bh=dAwH33eotjnlVsOht7d9rhAgXOscZtW9W2LYyToDBO4=; h=From:To:Cc:Subject:Date:From; b=TdCj0A3O6YwYAXNKf1a89qx5GjQuavcXgvtnvXgyZ4ei8FFqnc/0Evi0lpmSyQdIW d0hZz/7O173ix08Yc75HjUpWzQfNtqPAEIbm03qhhCBTofvap4tHMlr58xxsnDhvy2 kZCJHCA03l+obkz7uP5fMbarjv3lUHQYSI/WJVQ8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B4791605A4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: stable@vger.kernel.org Cc: linux-mtd@lists.infradead.org, Miquel Raynal , linux-arm-msm@vger.kernel.org, Abhishek Sahu , Boris Brezillon Subject: [BACKPORT PATCH] mtd: nand: fix return value check for bad block status Date: Tue, 3 Jul 2018 19:04:05 +0530 Message-Id: <1530624845-28319-1-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit e9893e6fa932f42c90c4ac5849fa9aa0f0f00a34 upstream. Positive return value from read_oob() is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC and read_oob() will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD. Fixes: c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check") Cc: Signed-off-by: Abhishek Sahu Reviewed-by: Miquel Raynal Signed-off-by: Boris Brezillon [backported to 4.14.y] Signed-off-by: Abhishek Sahu --- This is backported patch for failed patch mentioned in https://www.spinics.net/lists/stable/msg245833.html The failure happened due to file rename. drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 528e04f..d410de3 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs) for (; page < page_end; page++) { res = chip->ecc.read_oob(mtd, chip, page); - if (res) + if (res < 0) return res; bad = chip->oob_poi[chip->badblockpos];