Skip to contentSkip to conversation

EDAC, mpc85xx: Fix error return code in two functions

PATCH In review Zhen Lei 2 participants 4 messages May 28, 2021 – May 31, 2021

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 EDAC, mpc85xx: Fix error return code in two functions

Fix to return -EFAULT from the error handling case instead of 0, as done elsewhere in its function.

Fixes a9a753d53204 ("drivers-edac: add freescale mpc85xx driver")
---
 drivers/edac/mpc85xx_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/mpc85xx_edac.c +2 -0
index 67f7bc3fe5b3..b2eaa62c9412 100644
@@ -248,6 +248,7 @@ static int mpc85xx_pci_err_probe(struct platform_device *op)
 
 	if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
 		edac_dbg(3, "failed edac_pci_add_device()\n");
+		res = -EFAULT;
 		goto err;
 	}
 
@@ -552,6 +553,7 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 
 	if (edac_device_add_device(edac_dev) > 0) {
 		edac_dbg(3, "failed edac_device_add_device()\n");
+		res = -EFAULT;
 		goto err;
 	}
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 25 lines · Zhen Lei

Fix to return -EFAULT from the error handling case instead of 0, as done elsewhere in its function.

Fixes a9a753d53204 ("drivers-edac: add freescale mpc85xx driver")
---
 drivers/edac/mpc85xx_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/mpc85xx_edac.c +1 -0
index 67f7bc3fe5b3..b2eaa62c9412 100644
@@ -248,6 +248,7 @@ static int mpc85xx_pci_err_probe(struct platform_device *op)
 
 	if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
 		edac_dbg(3, "failed edac_pci_add_device()\n");
+		res = -EFAULT;
 
 		goto err;
 	}

drivers/edac/mpc85xx_edac.c static int mpc85xx_l2_err_probe(struct platform_device *op) · line 559

Quoted 7 lines
drivers/edac/mpc85xx_edac.c +1 -0
@@ -552,6 +553,7 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 
 	if (edac_device_add_device(edac_dev) > 0) {
 		edac_dbg(3, "failed edac_device_add_device()\n");
+		res = -EFAULT;
 		goto err;
 	}
 

EFAULT means

#define EFAULT 14 /* Bad address */

Does it make sense to you when the probe function returns a "bad address" upon failure to add a device?

hint 1: you might wanna audit how the other drivers are calling this for better ideas.

hint 2: while doing hint 1, you might find some more broken cases which you could fix too.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 36 lines · Borislav Petkov
Quoted 25 lines · Zhen Lei

Fix to return -EFAULT from the error handling case instead of 0, as done elsewhere in its function.

Fixes a9a753d53204 ("drivers-edac: add freescale mpc85xx driver")
---
 drivers/edac/mpc85xx_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/mpc85xx_edac.c +1 -0
index 67f7bc3fe5b3..b2eaa62c9412 100644
@@ -248,6 +248,7 @@ static int mpc85xx_pci_err_probe(struct platform_device *op)
 
 	if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
 		edac_dbg(3, "failed edac_pci_add_device()\n");
+		res = -EFAULT;
 
 		goto err;
 	}

drivers/edac/mpc85xx_edac.c static int mpc85xx_l2_err_probe(struct platform_device *op) · line 559

Quoted 7 lines
drivers/edac/mpc85xx_edac.c +1 -0
@@ -552,6 +553,7 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 
 	if (edac_device_add_device(edac_dev) > 0) {
 		edac_dbg(3, "failed edac_device_add_device()\n");
+		res = -EFAULT;
 		goto err;
 	}
 

EFAULT means

Quoted 7 lines

#define EFAULT 14 /* Bad address */

Does it make sense to you when the probe function returns a "bad address" upon failure to add a device?

hint 1: you might wanna audit how the other drivers are calling this for better ideas.

So how about change to -ENODEV?

Quoted 3 lines

hint 2: while doing hint 1, you might find some more broken cases which you could fix too.

OK, I will find and fix all of them. Thanks for your hint.

Quoted 3 lines

Thx.

maintainer
#3 lore raw
Quoted 1 line · Leizhen (ThunderTown)

So how about change to -ENODEV?

Yah, better.

Signature · 4 lines
Regards/Gruss,
    Boris.

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