All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
@ 2017-11-18 13:27 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-11-18 13:27 UTC (permalink / raw)
  To: kyungmin.park, dwmw2, computersforpeace, boris.brezillon,
	marek.vasut, richard, cyrille.pitchen
  Cc: linux-mtd, linux-kernel, kernel-janitors, Christophe JAILLET

If 'platform_get_resource()' fails, we have to go through the error
handling path to release some resources.

The unreachable 'goto ahb_resource_failed' is also wrong here and we should
go to 'resource_failed' instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mtd/onenand/samsung.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index af0ac1a7bf8f..164ebe2b1137 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENOENT;
-		goto ahb_resource_failed;
+		err = -ENOENT;
+		goto resource_failed;
 	}
 
 	onenand->base_res = request_mem_region(r->start, resource_size(r),
-- 
2.14.1

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

* [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
@ 2017-11-18 13:27 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-11-18 13:27 UTC (permalink / raw)
  To: kyungmin.park, dwmw2, computersforpeace, boris.brezillon,
	marek.vasut, richard, cyrille.pitchen
  Cc: linux-mtd, linux-kernel, kernel-janitors, Christophe JAILLET

If 'platform_get_resource()' fails, we have to go through the error
handling path to release some resources.

The unreachable 'goto ahb_resource_failed' is also wrong here and we should
go to 'resource_failed' instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mtd/onenand/samsung.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index af0ac1a7bf8f..164ebe2b1137 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENOENT;
-		goto ahb_resource_failed;
+		err = -ENOENT;
+		goto resource_failed;
 	}
 
 	onenand->base_res = request_mem_region(r->start, resource_size(r),
-- 
2.14.1


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

* Re: [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
  2017-11-18 13:27 ` Christophe JAILLET
@ 2017-12-07 16:55   ` Boris Brezillon
  -1 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2017-12-07 16:55 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: kyungmin.park, dwmw2, computersforpeace, marek.vasut, richard,
	cyrille.pitchen, linux-mtd, linux-kernel, kernel-janitors

On Sat, 18 Nov 2017 14:27:23 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> If 'platform_get_resource()' fails, we have to go through the error
> handling path to release some resources.
> 
> The unreachable 'goto ahb_resource_failed' is also wrong here and we should
> go to 'resource_failed' instead.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/mtd/onenand/samsung.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
> index af0ac1a7bf8f..164ebe2b1137 100644
> --- a/drivers/mtd/onenand/samsung.c
> +++ b/drivers/mtd/onenand/samsung.c
> @@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!r) {
>  		dev_err(&pdev->dev, "no memory resource defined\n");
> -		return -ENOENT;
> -		goto ahb_resource_failed;
> +		err = -ENOENT;
> +		goto resource_failed;
>  	}
>  

Sorry but I'd really prefer to convert the driver to use devm_
functions instead of fixing a single error path.

>  	onenand->base_res = request_mem_region(r->start, resource_size(r),

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

* Re: [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
@ 2017-12-07 16:55   ` Boris Brezillon
  0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2017-12-07 16:55 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: kyungmin.park, dwmw2, computersforpeace, marek.vasut, richard,
	cyrille.pitchen, linux-mtd, linux-kernel, kernel-janitors

On Sat, 18 Nov 2017 14:27:23 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> If 'platform_get_resource()' fails, we have to go through the error
> handling path to release some resources.
> 
> The unreachable 'goto ahb_resource_failed' is also wrong here and we should
> go to 'resource_failed' instead.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/mtd/onenand/samsung.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
> index af0ac1a7bf8f..164ebe2b1137 100644
> --- a/drivers/mtd/onenand/samsung.c
> +++ b/drivers/mtd/onenand/samsung.c
> @@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!r) {
>  		dev_err(&pdev->dev, "no memory resource defined\n");
> -		return -ENOENT;
> -		goto ahb_resource_failed;
> +		err = -ENOENT;
> +		goto resource_failed;
>  	}
>  

Sorry but I'd really prefer to convert the driver to use devm_
functions instead of fixing a single error path.

>  	onenand->base_res = request_mem_region(r->start, resource_size(r),


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

* Re: [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
  2017-12-07 16:55   ` Boris Brezillon
@ 2017-12-08 21:15     ` Christophe JAILLET
  -1 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-12-08 21:15 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: kyungmin.park, dwmw2, computersforpeace, marek.vasut, richard,
	cyrille.pitchen, linux-mtd, linux-kernel, kernel-janitors

Le 07/12/2017 à 17:55, Boris Brezillon a écrit :
> On Sat, 18 Nov 2017 14:27:23 +0100
> Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
>
>> If 'platform_get_resource()' fails, we have to go through the error
>> handling path to release some resources.
>>
>> The unreachable 'goto ahb_resource_failed' is also wrong here and we should
>> go to 'resource_failed' instead.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/mtd/onenand/samsung.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
>> index af0ac1a7bf8f..164ebe2b1137 100644
>> --- a/drivers/mtd/onenand/samsung.c
>> +++ b/drivers/mtd/onenand/samsung.c
>> @@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>>   	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>   	if (!r) {
>>   		dev_err(&pdev->dev, "no memory resource defined\n");
>> -		return -ENOENT;
>> -		goto ahb_resource_failed;
>> +		err = -ENOENT;
>> +		goto resource_failed;
>>   	}
>>   
> Sorry but I'd really prefer to convert the driver to use devm_
> functions instead of fixing a single error path.

Thanks for your comment. devm_ functions greatly simplify the code.
I've proposed an update for that.

If I'm correct, this also helped to find two other bugs (un-balanced 
request_irq() and un-handled error code)

CJ

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

* Re: [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()'
@ 2017-12-08 21:15     ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-12-08 21:15 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: kyungmin.park, dwmw2, computersforpeace, marek.vasut, richard,
	cyrille.pitchen, linux-mtd, linux-kernel, kernel-janitors

Le 07/12/2017 à 17:55, Boris Brezillon a écrit :
> On Sat, 18 Nov 2017 14:27:23 +0100
> Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
>
>> If 'platform_get_resource()' fails, we have to go through the error
>> handling path to release some resources.
>>
>> The unreachable 'goto ahb_resource_failed' is also wrong here and we should
>> go to 'resource_failed' instead.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/mtd/onenand/samsung.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
>> index af0ac1a7bf8f..164ebe2b1137 100644
>> --- a/drivers/mtd/onenand/samsung.c
>> +++ b/drivers/mtd/onenand/samsung.c
>> @@ -872,8 +872,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>>   	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>   	if (!r) {
>>   		dev_err(&pdev->dev, "no memory resource defined\n");
>> -		return -ENOENT;
>> -		goto ahb_resource_failed;
>> +		err = -ENOENT;
>> +		goto resource_failed;
>>   	}
>>   
> Sorry but I'd really prefer to convert the driver to use devm_
> functions instead of fixing a single error path.

Thanks for your comment. devm_ functions greatly simplify the code.
I've proposed an update for that.

If I'm correct, this also helped to find two other bugs (un-balanced 
request_irq() and un-handled error code)

CJ

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

end of thread, other threads:[~2017-12-08 21:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-18 13:27 [PATCH] mtd: onenand: Fix an error handling path in 's3c_onenand_probe(()' Christophe JAILLET
2017-11-18 13:27 ` Christophe JAILLET
2017-12-07 16:55 ` Boris Brezillon
2017-12-07 16:55   ` Boris Brezillon
2017-12-08 21:15   ` Christophe JAILLET
2017-12-08 21:15     ` Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.