Received: by 10.223.185.116 with SMTP id b49csp2219856wrg; Thu, 15 Feb 2018 08:17:27 -0800 (PST) X-Google-Smtp-Source: AH8x2259oj4zWI8CbRgZk25p1hpKpbDxF3GDs4lLXkIJlT2XdIHHQ0HQtLedy22AF971LcRxrATd X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr3014401pld.219.1518711447811; Thu, 15 Feb 2018 08:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518711447; cv=none; d=google.com; s=arc-20160816; b=pr+xcOIo9rtoDW+EuCI0AeX7LDJp/x3B5bXHresMqkKxsYYFOtwP1AA5jQfu5Gl7NN EnCZrmSRRZ56+T9qnRpERMEZDQaIp/JPanqqMKyjLpI6XV6J+hbKHutK41madUgwKeEP ndWMVE5/FoVMWuRK3o0PxEU0yXp6V/gqLei/RE7VXguGemjxIumKkxiNfrSTx1h1TovY BHHz6EUz0UQ1ckkU1X69IgatI4Wh8VVdDqeA5zZo+CZ1+QUFCkLkp5hhDypWktE2vrro ZQIT+TU699gS0+T3zjXdiFS9dHUx6sR1mvU4Uj/K4NLxwyjXDc2vN4KnVHwjfzJNMnOo TylQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PT1u34yU0a69Bnvh3sG4KCIkhLmXf7MTc8xu8qLStXw=; b=kWf23kBwSAPKLR3XL+XS1gHM8sLYBM6A0a4+odjZzWZS4yVQ1FNHs+S9InmHPxOvEw mU1mB4p3I7+kltb4eKV45qlVH9Lu0SzVLBEkV0g5IhvPZRnwyvuG+nH1oH6OmIccL5Sl 3NVLdBt7eEek/3pyyF4lctdHjuODiHhT7UtlHrE7ovNs2zpZ56U7Hz8Pj8uXKagN3Lzx YixhUYIeLU4xzLN2AY79v/xyVmZFCtxuBhJ03USNkJ18VucCt9ksf42hZO9Zi3Naq1+W fb3BaCRrZD6wcwvgLbfc8Cj96Nr4xVTISjO0556qWrZTV27PICfnbAGOqhfmrAOQ/Nfy SjfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 94-v6si1531195plf.451.2018.02.15.08.17.13; Thu, 15 Feb 2018 08:17:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1165485AbeBOPo3 (ORCPT + 99 others); Thu, 15 Feb 2018 10:44:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34362 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165417AbeBOPoZ (ORCPT ); Thu, 15 Feb 2018 10:44:25 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AE365117F; Thu, 15 Feb 2018 15:44:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Boris Brezillon Subject: [PATCH 4.15 090/202] mtd: nand: Fix nand_do_read_oob() return value Date: Thu, 15 Feb 2018 16:16:30 +0100 Message-Id: <20180215151718.135590802@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miquel Raynal commit 87e89ce8d0d14f573c068c61bec2117751fb5103 upstream. Starting from commit 041e4575f034 ("mtd: nand: handle ECC errors in OOB"), nand_do_read_oob() (from the NAND core) did return 0 or a negative error, and the MTD layer expected it. However, the trend for the NAND layer is now to return an error or a positive number of bitflips. Deciding which status to return to the user belongs to the MTD layer. Commit e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()") brought this logic to the mtd_read_oob() function while the return value coming from nand_do_read_oob() (called by the ->_read_oob() hook) was left unchanged. Fixes: e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()") Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/nand_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2199,6 +2199,7 @@ EXPORT_SYMBOL(nand_write_oob_syndrome); static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { + unsigned int max_bitflips = 0; int page, realpage, chipnr; struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_ecc_stats stats; @@ -2256,6 +2257,8 @@ static int nand_do_read_oob(struct mtd_i nand_wait_ready(mtd); } + max_bitflips = max_t(unsigned int, max_bitflips, ret); + readlen -= len; if (!readlen) break; @@ -2281,7 +2284,7 @@ static int nand_do_read_oob(struct mtd_i if (mtd->ecc_stats.failed - stats.failed) return -EBADMSG; - return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0; + return max_bitflips; } /**