Skip to contentSkip to conversation

n64: fix return value check in n64cart_probe()

PATCH In review Wei Yongjun 3 participants 3 messages Feb 23, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 n64: fix return value check in n64cart_probe()

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

Fixes d9b2a2bbbb4d ("block: Add n64 cart driver")
---
 drivers/block/n64cart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/n64cart.c +2 -2
index 47bdf324e962..84a0f8d0be29 100644
@@ -129,8 +129,8 @@ static int __init n64cart_probe(struct platform_device *pdev)
 	}
 
 	reg_base = devm_platform_ioremap_resource(pdev, 0);
-	if (!reg_base)
-		return -EINVAL;
+	if (IS_ERR(reg_base))
+		return ERR_PTR(reg_base);
 
 	disk = alloc_disk(0);
 	if (!disk)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · On Tue, 23 Feb 2021 14:01:04 +0000 Wei Yongjun <[email protected]> wrote:

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

Fixes d9b2a2bbbb4d ("block: Add n64 cart driver")
---
 drivers/block/n64cart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/n64cart.c +0 -0
index 47bdf324e962..84a0f8d0be29 100644

drivers/block/n64cart.c static int __init n64cart_probe(struct platform_device *pdev) · line 136

Quoted 10 lines
drivers/block/n64cart.c +2 -2
@@ -129,8 +129,8 @@ static int __init n64cart_probe(struct platform_device *pdev)
 	}
 
 	reg_base = devm_platform_ioremap_resource(pdev, 0);
-	if (!reg_base)
-		return -EINVAL;
+	if (IS_ERR(reg_base))
+		return ERR_PTR(reg_base);
 
 	disk = alloc_disk(0);
 	if (!disk)

- Lauri

Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Yongjun
Quoted 7 lines · Wei Yongjun

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

Fixes d9b2a2bbbb4d ("block: Add n64 cart driver")

Looks good.