Received: by 10.192.165.148 with SMTP id m20csp1778356imm; Thu, 3 May 2018 05:23:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZorMZS7UFCuLF1oK/SZOKmqKwT5ydGnYiqRvAkByhKL78tNIOgEY05/gjCEGjbRVz/JHpbl X-Received: by 2002:a17:902:ab83:: with SMTP id f3-v6mr23395438plr.344.1525350205431; Thu, 03 May 2018 05:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525350205; cv=none; d=google.com; s=arc-20160816; b=fGnLN9wICdZzCYMkQhV/5NQE0UquCov7/CPZ2V0JYIdGlCDBfecHZoYWkYfQdjlPsJ cwF3Dy9rxf3GtF1sgCqjXAuFjJK0ljq3VckUqpqJQW8LaJSJICT1S5NL6Iy4UiGD3g+7 Yb8i30Aj6RcakdgLkbztcJBlOKn5rX3nBrit9bc2Y3l6RJxeA1mhwwlQCELebHycxEx0 LdsTV8orqfehQfuBTCwhhWKN+o5ja44q/yu5DbGPYBUDQ2ITYXEDYks8HgDYQzhFYPfR vVUCIDcizKjinl2N9/jqKAnK2TWoCyAQO7NArI89ubf2Qq/9PZsD2tG2MQxytE5PVUFe 8VZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=x0ZdggIsgJcJE8hsC7/Ub/ATXUit/tap0S8DUf+9Ids=; b=OTdRVJeCqwEj3y1aLlDGBI1kT/bcIDhP+NygHVD67E7KIOGGNRuR7SFFQfezJS4D2K wnFMrmaczuJfP1NsGAGTJ9yaSfwbdIKl+mDhDgc+dT0GCCL9PPs9IX08KdItOBnCYlUF SZGbSgtx2iKv6hkdDpNC66J+pbW/XPCmWy8RUUhOV5gSpHRD7YkqrdPi8OOG7uNZma5R 0swIL8BTjsetyjNOUT4yqbnVLJ4DC6XvbuYD9545JL54aXJmNMLPrHASGGIlxW8X5Nqt dqTXz9DFI4jvKg17mDNZM6lU4sCs7xshNoLULD5hiIAouU32UzXX7xVIh5064erQaFi0 s94w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=T02iQsZx; dkim=pass header.i=@codeaurora.org header.s=default header.b=WWsd+2S2; 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 c11-v6si12824898pll.102.2018.05.03.05.23.10; Thu, 03 May 2018 05:23:25 -0700 (PDT) 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; dkim=pass header.i=@codeaurora.org header.s=default header.b=T02iQsZx; dkim=pass header.i=@codeaurora.org header.s=default header.b=WWsd+2S2; 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 S1751240AbeECMVc (ORCPT + 99 others); Thu, 3 May 2018 08:21:32 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42150 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeECMV1 (ORCPT ); Thu, 3 May 2018 08:21:27 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EB8D660807; Thu, 3 May 2018 12:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350086; bh=m93s3Stw89uw5L5s7ZV0mCFqh734hTMrgdGL8Bu/YcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T02iQsZxMEof2ybUp9MwFyS7patQm9ywgGPCRT7v3sIHCqDR9c8cV35HnL/DEVv7U sa74J6rTHnzwzqR3eqJWioE2kEfBCq3keF7wmVGI7dXTw301jP5cHO3oUHJp9EUvrY uyhRZinGYIEKRiqzWAQp0qSX6QT3dDWtqOPbOYQ0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 B7C1B60807; Thu, 3 May 2018 12:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350085; bh=m93s3Stw89uw5L5s7ZV0mCFqh734hTMrgdGL8Bu/YcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWsd+2S2wCyNOyrLEtrhgYh8R5LYPLCk994ElEEwHH59dSSOeY4z4m2Duikax4CHn WPeYhk+dVlJ5P+hHgR6f/+SZY2K2OoBPv6VCFusBJUYHzpOljlH1pbUP7l5qb6KREU P36PHJ+cXtwltpqrJeirI705Vq8bsqLNvu0+mayo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B7C1B60807 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: Boris Brezillon Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Miquel Raynal , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andy Gross , Archit Taneja , Abhishek Sahu Subject: [PATCH v2 07/14] mtd: rawnand: qcom: fix null pointer access for erased page detection Date: Thu, 3 May 2018 17:50:34 +0530 Message-Id: <1525350041-22995-8-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> References: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org parse_read_errors can be called with only oob_buf in which case data_buf will be NULL. If data_buf is NULL, then don’t treat this page as completely erased in case of ECC uncorrectable error for RS ECC. For BCH ECC, the controller itself tells regarding erased page in status register. Signed-off-by: Abhishek Sahu --- * Changes from v1: 1. Added more detail in commit message 2. Added comment before each if/else drivers/mtd/nand/raw/qcom_nandc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index e6a21598..fa38142 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -1613,13 +1613,24 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, int ret, ecclen, extraooblen; void *eccbuf; - /* ignore erased codeword errors */ + /* + * For BCH ECC, ignore erased codeword errors, if + * ERASED_CW bits are set. + */ if (host->bch_enabled) { erased = (erased_cw & ERASED_CW) == ERASED_CW ? true : false; - } else { + /* + * For RS ECC, HW reports the erased CW by placing + * special characters at certain offsets in the buffer. + * These special characters will be valid only if + * complete page is read i.e. data_buf is not NULL. + */ + } else if (data_buf) { erased = erased_chunk_check_and_fixup(data_buf, data_len); + } else { + erased = false; } if (erased) { @@ -1667,7 +1678,8 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, max_bitflips = max(max_bitflips, stat); } - data_buf += data_len; + if (data_buf) + data_buf += data_len; if (oob_buf) oob_buf += oob_len + ecc->bytes; } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation