linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: raw: qcom_nandc: handle ret from parse with codeword_fixup
@ 2022-10-21 16:53 Christian Marangi
  2022-11-07 16:20 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Marangi @ 2022-10-21 16:53 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Christian Marangi, linux-mtd, linux-arm-msm,
	linux-kernel
  Cc: stable

With use_codeword_fixup enabled, any return from
mtd_device_parse_register gets overwritten. Aside from the clear bug, this
is also problematic as a parser can EPROBE_DEFER and because this is not
correctly handled, the nand is never rescanned later in the bootup
process.

An example of this problem is when smem requires additional time to be
probed and nandc use qcomsmempart as parser. Parser will return
EPROBE_DEFER but in the current code this ret gets overwritten by
qcom_nand_host_parse_boot_partitions and qcom_nand_host_init_and_register
return 0.

Correctly handle the return code from mtd_device_parse_register so that
any error from this function is not ignored.

Fixes: 862bdedd7f4b ("mtd: nand: raw: qcom_nandc: add support for unprotected spare data pages")
Cc: stable@vger.kernel.org # v6.0+
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 8f80019a9f01..198a44794d2d 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -3167,16 +3167,18 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
 
 	ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
 	if (ret)
-		nand_cleanup(chip);
+		goto err;
 
 	if (nandc->props->use_codeword_fixup) {
 		ret = qcom_nand_host_parse_boot_partitions(nandc, host, dn);
-		if (ret) {
-			nand_cleanup(chip);
-			return ret;
-		}
+		if (ret)
+			goto err;
 	}
 
+	return 0;
+
+err:
+	nand_cleanup(chip);
 	return ret;
 }
 
-- 
2.37.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: nand: raw: qcom_nandc: handle ret from parse with codeword_fixup
  2022-10-21 16:53 [PATCH] mtd: nand: raw: qcom_nandc: handle ret from parse with codeword_fixup Christian Marangi
@ 2022-11-07 16:20 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-11-07 16:20 UTC (permalink / raw)
  To: Christian Marangi, Manivannan Sadhasivam, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-mtd,
	linux-arm-msm, linux-kernel
  Cc: stable

On Fri, 2022-10-21 at 16:53:04 UTC, Christian Marangi wrote:
> With use_codeword_fixup enabled, any return from
> mtd_device_parse_register gets overwritten. Aside from the clear bug, this
> is also problematic as a parser can EPROBE_DEFER and because this is not
> correctly handled, the nand is never rescanned later in the bootup
> process.
> 
> An example of this problem is when smem requires additional time to be
> probed and nandc use qcomsmempart as parser. Parser will return
> EPROBE_DEFER but in the current code this ret gets overwritten by
> qcom_nand_host_parse_boot_partitions and qcom_nand_host_init_and_register
> return 0.
> 
> Correctly handle the return code from mtd_device_parse_register so that
> any error from this function is not ignored.
> 
> Fixes: 862bdedd7f4b ("mtd: nand: raw: qcom_nandc: add support for unprotected spare data pages")
> Cc: stable@vger.kernel.org # v6.0+
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-07 16:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 16:53 [PATCH] mtd: nand: raw: qcom_nandc: handle ret from parse with codeword_fixup Christian Marangi
2022-11-07 16:20 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).