OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | From 42ebff638003be18fab503b37de4ad7853244e95 Mon Sep 17 00:00:00 2001 |
2 | From: Ezequiel Garcia <ezequiel.garcia@imgtec.com> |
||
3 | Date: Sat, 25 Feb 2017 15:58:22 +0000 |
||
4 | Subject: mtd: nand: Check length of ID before reading bits per cell |
||
5 | |||
6 | The table-based NAND identification currently reads the number |
||
7 | of bits per cell from the 3rd byte of the extended ID. This is done |
||
8 | for the so-called 'full ID' devices; i.e. devices that have a known |
||
9 | length ID. |
||
10 | |||
11 | However, if the ID length is shorter than three, there's no 3rd byte, |
||
12 | and so it's wrong to read the bits per cell from there. Fix this by |
||
13 | adding a check for the ID length. |
||
14 | |||
15 | (picked from http://lists.infradead.org/pipermail/linux-mtd/2014-December/056764.html) |
||
16 | |||
17 | Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com> |
||
18 | --- |
||
19 | drivers/mtd/nand/nand_base.c | 3 ++- |
||
20 | 1 file changed, 2 insertions(+), 1 deletion(-) |
||
21 | |||
22 | --- a/drivers/mtd/nand/nand_base.c |
||
23 | +++ b/drivers/mtd/nand/nand_base.c |
||
24 | @@ -3803,7 +3803,8 @@ static bool find_full_id_nand(struct nan |
||
25 | mtd->erasesize = type->erasesize; |
||
26 | mtd->oobsize = type->oobsize; |
||
27 | |||
28 | - chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
||
29 | + if (type->id_len > 2) |
||
30 | + chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
||
31 | chip->chipsize = (uint64_t)type->chipsize << 20; |
||
32 | chip->options |= type->options; |
||
33 | chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); |