[PATCH] mtd: rawnand: make rawnand_check_data_only_read_support() work

Sascha Hauer s.hauer at pengutronix.de
Tue May 14 03:33:55 PDT 2024


rawnand_check_data_only_read_support() calls nand_read_data_op() with a
NULL pointer as buffer which will immediately return an error. Allow a
NULL buffer pointer when check_only is requested. This should be safe to
do as nand_read_data_op() has no business in touching the buffer in
check_only mode.

Fixes: 9f820fc0651c ("mtd: rawnand: Check the data only read pattern only once")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/nand/raw/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index d7dbbd469b892..a5e7d8deafbbe 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -2173,7 +2173,7 @@ EXPORT_SYMBOL_GPL(nand_reset_op);
 int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
 		      bool force_8bit, bool check_only)
 {
-	if (!len || !buf)
+	if (!len || (!buf && !check_only))
 		return -EINVAL;
 
 	if (nand_has_exec_op(chip)) {
-- 
2.39.2




More information about the linux-mtd mailing list