summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/raw/qcom_nandc.c
diff options
context:
space:
mode:
authorAbhishek Sahu <absahu@codeaurora.org>2018-06-20 12:57:35 +0530
committerMiquel Raynal <miquel.raynal@bootlin.com>2018-07-18 09:24:07 +0200
commit2f610386736d9e5dc69fa06374138f9712690921 (patch)
treed8de43e97eb20445248b71974c3b3697cdbdbf7d /drivers/mtd/nand/raw/qcom_nandc.c
parent8eab72148808a74535c3322f6ca30aba77d2d4a9 (diff)
downloadlwn-2f610386736d9e5dc69fa06374138f9712690921.tar.gz
lwn-2f610386736d9e5dc69fa06374138f9712690921.zip
mtd: rawnand: qcom: fix null pointer access for erased page detection
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 <absahu@codeaurora.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'drivers/mtd/nand/raw/qcom_nandc.c')
-rw-r--r--drivers/mtd/nand/raw/qcom_nandc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 0d931d51f85a..a831f9cb458a 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -1611,13 +1611,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) {
@@ -1665,7 +1676,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;
}