Skip to contentSkip to conversation

EDAC/sifive: fix return value check in ecc_register()

PATCH Applied Wei Yongjun 2 participants 2 messages Jan 15, 2020 – Jan 17, 2020

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

PATCH 1/1 EDAC/sifive: fix return value check in ecc_register()

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

Fixes 91abaeaaff35 ("EDAC/sifive: Add EDAC platform driver for SiFive SoCs")
---
 drivers/edac/sifive_edac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/sifive_edac.c +2 -2
index c0cc72a3b2be..3a3dcb14ed99 100644
@@ -54,8 +54,8 @@ static int ecc_register(struct platform_device *pdev)
 	p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
 					    1, 1, NULL, 0,
 					    edac_device_alloc_index());
-	if (IS_ERR(p->dci))
-		return PTR_ERR(p->dci);
+	if (!p->dci)
+		return -ENOMEM;
 
 	p->dci->dev = &pdev->dev;
 	p->dci->mod_name = "Sifive ECC Manager";
maintainer Applied
#1 lore raw
Quoted 15 lines · Wei Yongjun

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

Fixes 91abaeaaff35 ("EDAC/sifive: Add EDAC platform driver for SiFive SoCs")
---
 drivers/edac/sifive_edac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/sifive_edac.c +0 -0
index c0cc72a3b2be..3a3dcb14ed99 100644

drivers/edac/sifive_edac.c static int ecc_register(struct platform_device *pdev) · line 61

Quoted 10 lines
drivers/edac/sifive_edac.c +2 -2
@@ -54,8 +54,8 @@ static int ecc_register(struct platform_device *pdev)
 	p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
 					    1, 1, NULL, 0,
 					    edac_device_alloc_index());
-	if (IS_ERR(p->dci))
-		return PTR_ERR(p->dci);
+	if (!p->dci)
+		return -ENOMEM;
 
 	p->dci->dev = &pdev->dev;
 	p->dci->mod_name = "Sifive ECC Manager";

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette