Skip to contentSkip to conversation

memory: jz4780-nemc: Fix return value check in jz4780_nemc_probe()

PATCH In review Wei Yongjun 2 participants 2 messages Aug 4, 2020

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

PATCH 1/1 memory: jz4780-nemc: Fix return value check in jz4780_nemc_probe()

In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the driver will use")
---
 drivers/memory/jz4780-nemc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/memory/jz4780-nemc.c +2 -2
index 3ec5cb0fce1e..608ae925e641 100644
@@ -304,9 +304,9 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
 	}
 
 	nemc->base = devm_ioremap(dev, res->start, NEMC_REG_LEN);
-	if (IS_ERR(nemc->base)) {
+	if (!nemc->base) {
 		dev_err(dev, "failed to get I/O memory\n");
-		return PTR_ERR(nemc->base);
+		return -ENOMEM;
 	}
 
 	writel(0, nemc->base + NEMC_NFCSR);
#1 lore raw
Quoted 10 lines · Wei Yongjun

In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the driver will use")
---
 drivers/memory/jz4780-nemc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks for the patch. The fix was already posted by Dan:
https://lore.kernel.org/lkml/20200803143607.GC346925@mwanda/

Best regards,
Krzysztof