linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions
@ 2021-05-28  3:26 Zhen Lei
  2021-05-31  8:40 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Zhen Lei @ 2021-05-28  3:26 UTC (permalink / raw)
  To: Johannes Thumshirn, Borislav Petkov, Mauro Carvalho Chehab,
	Tony Luck, James Morse, Robert Richter, Doug Thompson,
	Dave Jiang, Andrew Morton, linux-edac, linux-kernel
  Cc: 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")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/edac/mpc85xx_edac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 67f7bc3fe5b3..b2eaa62c9412 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -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;
 	}
 
-- 
2.25.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions
  2021-05-28  3:26 [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions Zhen Lei
@ 2021-05-31  8:40 ` Borislav Petkov
  2021-05-31  9:15   ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2021-05-31  8:40 UTC (permalink / raw)
  To: Zhen Lei
  Cc: Johannes Thumshirn, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Doug Thompson, Dave Jiang,
	Andrew Morton, linux-edac, linux-kernel

On Fri, May 28, 2021 at 11:26:37AM +0800, Zhen Lei wrote:
> 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")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  drivers/edac/mpc85xx_edac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
> index 67f7bc3fe5b3..b2eaa62c9412 100644
> --- a/drivers/edac/mpc85xx_edac.c
> +++ b/drivers/edac/mpc85xx_edac.c
> @@ -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;
>  	}
>  
> -- 

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.

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions
  2021-05-31  8:40 ` Borislav Petkov
@ 2021-05-31  9:15   ` Leizhen (ThunderTown)
  2021-05-31  9:23     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Leizhen (ThunderTown) @ 2021-05-31  9:15 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Johannes Thumshirn, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Doug Thompson, Dave Jiang,
	Andrew Morton, linux-edac, linux-kernel



On 2021/5/31 16:40, Borislav Petkov wrote:
> On Fri, May 28, 2021 at 11:26:37AM +0800, Zhen Lei wrote:
>> 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")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  drivers/edac/mpc85xx_edac.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
>> index 67f7bc3fe5b3..b2eaa62c9412 100644
>> --- a/drivers/edac/mpc85xx_edac.c
>> +++ b/drivers/edac/mpc85xx_edac.c
>> @@ -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;
>>  	}
>>  
>> -- 
> 
> 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.

So how about change to -ENODEV?

> 
> 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.

> 
> Thx.
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions
  2021-05-31  9:15   ` Leizhen (ThunderTown)
@ 2021-05-31  9:23     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2021-05-31  9:23 UTC (permalink / raw)
  To: Leizhen (ThunderTown)
  Cc: Johannes Thumshirn, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Doug Thompson, Dave Jiang,
	Andrew Morton, linux-edac, linux-kernel

On Mon, May 31, 2021 at 05:15:54PM +0800, Leizhen (ThunderTown) wrote:
> So how about change to -ENODEV?

Yah, better.

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-31  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28  3:26 [PATCH 1/1] EDAC, mpc85xx: Fix error return code in two functions Zhen Lei
2021-05-31  8:40 ` Borislav Petkov
2021-05-31  9:15   ` Leizhen (ThunderTown)
2021-05-31  9:23     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).