2e7e6833bb8edc8ddc28019ec3ee092e4fd862b7
[openwrt/staging/pepe2k.git] /
1 From 7df140e84a75c89962feef659d686303d3ce75e5 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 21 Oct 2022 18:53:04 +0200
4 Subject: [PATCH] mtd: rawnand: qcom: handle ret from parse with codeword_fixup
5
6 With use_codeword_fixup enabled, any return from
7 mtd_device_parse_register gets overwritten. Aside from the clear bug, this
8 is also problematic as a parser can EPROBE_DEFER and because this is not
9 correctly handled, the nand is never rescanned later in the bootup
10 process.
11
12 An example of this problem is when smem requires additional time to be
13 probed and nandc use qcomsmempart as parser. Parser will return
14 EPROBE_DEFER but in the current code this ret gets overwritten by
15 qcom_nand_host_parse_boot_partitions and qcom_nand_host_init_and_register
16 return 0.
17
18 Correctly handle the return code from mtd_device_parse_register so that
19 any error from this function is not ignored.
20
21 Fixes: 862bdedd7f4b ("mtd: nand: raw: qcom_nandc: add support for unprotected spare data pages")
22 Cc: stable@vger.kernel.org # v6.0+
23 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
24 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
25 Link: https://lore.kernel.org/linux-mtd/20221021165304.19991-1-ansuelsmth@gmail.com
26 ---
27 drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++++-----
28 1 file changed, 7 insertions(+), 5 deletions(-)
29
30 --- a/drivers/mtd/nand/raw/qcom_nandc.c
31 +++ b/drivers/mtd/nand/raw/qcom_nandc.c
32 @@ -3157,16 +3157,18 @@ static int qcom_nand_host_init_and_regis
33
34 ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
35 if (ret)
36 - nand_cleanup(chip);
37 + goto err;
38
39 if (nandc->props->use_codeword_fixup) {
40 ret = qcom_nand_host_parse_boot_partitions(nandc, host, dn);
41 - if (ret) {
42 - nand_cleanup(chip);
43 - return ret;
44 - }
45 + if (ret)
46 + goto err;
47 }
48
49 + return 0;
50 +
51 +err:
52 + nand_cleanup(chip);
53 return ret;
54 }
55