Skip to content

Commit 2f61038

Browse files
Abhishek Sahumiquelraynal
authored andcommitted
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>
1 parent 8eab721 commit 2f61038

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/mtd/nand/raw/qcom_nandc.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,13 +1611,24 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf,
16111611
int ret, ecclen, extraooblen;
16121612
void *eccbuf;
16131613

1614-
/* ignore erased codeword errors */
1614+
/*
1615+
* For BCH ECC, ignore erased codeword errors, if
1616+
* ERASED_CW bits are set.
1617+
*/
16151618
if (host->bch_enabled) {
16161619
erased = (erased_cw & ERASED_CW) == ERASED_CW ?
16171620
true : false;
1618-
} else {
1621+
/*
1622+
* For RS ECC, HW reports the erased CW by placing
1623+
* special characters at certain offsets in the buffer.
1624+
* These special characters will be valid only if
1625+
* complete page is read i.e. data_buf is not NULL.
1626+
*/
1627+
} else if (data_buf) {
16191628
erased = erased_chunk_check_and_fixup(data_buf,
16201629
data_len);
1630+
} else {
1631+
erased = false;
16211632
}
16221633

16231634
if (erased) {
@@ -1665,7 +1676,8 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf,
16651676
max_bitflips = max(max_bitflips, stat);
16661677
}
16671678

1668-
data_buf += data_len;
1679+
if (data_buf)
1680+
data_buf += data_len;
16691681
if (oob_buf)
16701682
oob_buf += oob_len + ecc->bytes;
16711683
}

0 commit comments

Comments
 (0)