Skip to contentSkip to conversation

mtd: nand: realtek-ecc: Fix a IS_ERR() vs NULL bug in probe

PATCH Applied Dan Carpenter 4 participants 4 messages Oct 3, 2025 – Oct 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: realtek-ecc: Fix a IS_ERR() vs NULL bug in probe

The dma_alloc_noncoherent() function doesn't return error pointers, it returns NULL on error. Fix the error checking to match.

Fixes 3148d0e5b1c5 ("mtd: nand: realtek-ecc: Add Realtek external ECC engine support")
---
 drivers/mtd/nand/ecc-realtek.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/ecc-realtek.c +2 -2
index 7d718934c909..7c275f1eb4a7 100644
@@ -418,8 +418,8 @@ static int rtl_ecc_probe(struct platform_device *pdev)
 
 	rtlc->buf = dma_alloc_noncoherent(dev, RTL_ECC_DMA_SIZE, &rtlc->buf_dma,
 					  DMA_BIDIRECTIONAL, GFP_KERNEL);
-	if (IS_ERR(rtlc->buf))
-		return PTR_ERR(rtlc->buf);
+	if (!rtlc->buf)
+		return -ENOMEM;
 
 	rtlc->dev = dev;
 	rtlc->engine.dev = dev;
Signature · 1 line
2.51.0
#1 lore raw
Quoted 5 lines

Von: Dan Carpenter <[email protected]>
Gesendet: Freitag, 3. Oktober 2025 11:30

The dma_alloc_noncoherent() function doesn't return error pointers, it returns NULL on error. Fix the error checking to match.

Hi Dan,

thanks for the quick fix.

Markus

Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

The dma_alloc_noncoherent() function doesn't return error pointers, it returns NULL on error. Fix the error checking to match.

Fixes 3148d0e5b1c5 ("mtd: nand: realtek-ecc: Add Realtek external ECC engine support")

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Applied
#3 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The dma_alloc_noncoherent() function doesn't return error pointers, it returns NULL on error. Fix the error checking to match.

Applied to mtd/fixes, thanks!

[1/1] mtd: nand: realtek-ecc: Fix a IS_ERR() vs NULL bug in probe

      commit: 9225f02ff201837e1443076f37a3c008140d1835

Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl