linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration
@ 2021-04-23 10:18 Krzysztof Kozlowski
  2021-04-23 10:18 ` [PATCH 2/2] memory: atmel-ebi: " Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-23 10:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, Maxime Coquelin, Alexandre Torgue,
	Christophe Kerello, Miquel Raynal, Boris Brezillon, linux-kernel,
	linux-arm-kernel, linux-stm32

Early exits from for_each_available_child_of_node() should decrement the
node reference counter.  Reported by Coccinelle:

  drivers/memory/stm32-fmc2-ebi.c:1046:1-33: WARNING:
    Function "for_each_available_child_of_node" should have of_node_put() before return around line 1051.

Fixes: 66b8173a197f ("memory: stm32-fmc2-ebi: add STM32 FMC2 EBI controller driver")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/memory/stm32-fmc2-ebi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-ebi.c
index 4d5758c419c5..ffec26a99313 100644
--- a/drivers/memory/stm32-fmc2-ebi.c
+++ b/drivers/memory/stm32-fmc2-ebi.c
@@ -1048,16 +1048,19 @@ static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi)
 		if (ret) {
 			dev_err(dev, "could not retrieve reg property: %d\n",
 				ret);
+			of_node_put(child);
 			return ret;
 		}
 
 		if (bank >= FMC2_MAX_BANKS) {
 			dev_err(dev, "invalid reg value: %d\n", bank);
+			of_node_put(child);
 			return -EINVAL;
 		}
 
 		if (ebi->bank_assigned & BIT(bank)) {
 			dev_err(dev, "bank already assigned: %d\n", bank);
+			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -1066,6 +1069,7 @@ static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi)
 			if (ret) {
 				dev_err(dev, "setup chip select %d failed: %d\n",
 					bank, ret);
+				of_node_put(child);
 				return ret;
 			}
 		}
-- 
2.25.1


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

* [PATCH 2/2] memory: atmel-ebi: add missing of_node_put for loop iteration
  2021-04-23 10:18 [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration Krzysztof Kozlowski
@ 2021-04-23 10:18 ` Krzysztof Kozlowski
  2021-04-23 12:02 ` [Linux-stm32] [PATCH 1/2] memory: stm32-fmc2-ebi: " Christophe Kerello
  2021-05-11 12:49 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-23 10:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, Maxime Coquelin, Alexandre Torgue,
	Christophe Kerello, Miquel Raynal, Boris Brezillon, linux-kernel,
	linux-arm-kernel, linux-stm32

Early exits from for_each_available_child_of_node() should decrement the
node reference counter.  Reported by Coccinelle:

  drivers/memory/atmel-ebi.c:593:1-33: WARNING:
    Function "for_each_available_child_of_node" should have of_node_put() before return around line 604.

Fixes: 6a4ec4cd0888 ("memory: add Atmel EBI (External Bus Interface) driver")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/memory/atmel-ebi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 14386d0b5f57..c267283b01fd 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -600,8 +600,10 @@ static int atmel_ebi_probe(struct platform_device *pdev)
 				child);
 
 			ret = atmel_ebi_dev_disable(ebi, child);
-			if (ret)
+			if (ret) {
+				of_node_put(child);
 				return ret;
+			}
 		}
 	}
 
-- 
2.25.1


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

* Re: [Linux-stm32] [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration
  2021-04-23 10:18 [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration Krzysztof Kozlowski
  2021-04-23 10:18 ` [PATCH 2/2] memory: atmel-ebi: " Krzysztof Kozlowski
@ 2021-04-23 12:02 ` Christophe Kerello
  2021-05-11 12:49 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Christophe Kerello @ 2021-04-23 12:02 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, Maxime Coquelin, Alexandre Torgue,
	Christophe Kerello, Miquel Raynal, Boris Brezillon, linux-kernel,
	linux-arm-kernel, linux-stm32

Hi Krzysztof,

On 4/23/21 12:18 PM, Krzysztof Kozlowski wrote:
> Early exits from for_each_available_child_of_node() should decrement the
> node reference counter.  Reported by Coccinelle:
> 
>    drivers/memory/stm32-fmc2-ebi.c:1046:1-33: WARNING:
>      Function "for_each_available_child_of_node" should have of_node_put() before return around line 1051.
> 
> Fixes: 66b8173a197f ("memory: stm32-fmc2-ebi: add STM32 FMC2 EBI controller driver")
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
>   drivers/memory/stm32-fmc2-ebi.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-ebi.c
> index 4d5758c419c5..ffec26a99313 100644
> --- a/drivers/memory/stm32-fmc2-ebi.c
> +++ b/drivers/memory/stm32-fmc2-ebi.c
> @@ -1048,16 +1048,19 @@ static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi)
>   		if (ret) {
>   			dev_err(dev, "could not retrieve reg property: %d\n",
>   				ret);
> +			of_node_put(child);
>   			return ret;
>   		}
>   
>   		if (bank >= FMC2_MAX_BANKS) {
>   			dev_err(dev, "invalid reg value: %d\n", bank);
> +			of_node_put(child);
>   			return -EINVAL;
>   		}
>   
>   		if (ebi->bank_assigned & BIT(bank)) {
>   			dev_err(dev, "bank already assigned: %d\n", bank);
> +			of_node_put(child);
>   			return -EINVAL;
>   		}
>   
> @@ -1066,6 +1069,7 @@ static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi)
>   			if (ret) {
>   				dev_err(dev, "setup chip select %d failed: %d\n",
>   					bank, ret);
> +				of_node_put(child);
>   				return ret;
>   			}
>   		}
>

Reviewed-by: Christophe Kerello <christophe.kerello@foss.st.com>

Regards,
Christophe Kerello.


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

* Re: [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration
  2021-04-23 10:18 [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration Krzysztof Kozlowski
  2021-04-23 10:18 ` [PATCH 2/2] memory: atmel-ebi: " Krzysztof Kozlowski
  2021-04-23 12:02 ` [Linux-stm32] [PATCH 1/2] memory: stm32-fmc2-ebi: " Christophe Kerello
@ 2021-05-11 12:49 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-11 12:49 UTC (permalink / raw)
  To: linux-arm-kernel, Miquel Raynal, Maxime Coquelin,
	Krzysztof Kozlowski, linux-kernel, Christophe Kerello,
	Nicolas Ferre, Ludovic Desroches, Alexandre Torgue, linux-stm32,
	Alexandre Belloni, Boris Brezillon

On Fri, 23 Apr 2021 12:18:14 +0200, Krzysztof Kozlowski wrote:
> Early exits from for_each_available_child_of_node() should decrement the
> node reference counter.  Reported by Coccinelle:
> 
>   drivers/memory/stm32-fmc2-ebi.c:1046:1-33: WARNING:
>     Function "for_each_available_child_of_node" should have of_node_put() before return around line 1051.

Applied, thanks!

[1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration
      commit: 2f9dc6a357ff3b82c1e54d29fb5d52b8d4a0c587
[2/2] memory: atmel-ebi: add missing of_node_put for loop iteration
      commit: 907c5bbb514a4676160e79764522fff56ce3448e

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

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

end of thread, other threads:[~2021-05-11 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 10:18 [PATCH 1/2] memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration Krzysztof Kozlowski
2021-04-23 10:18 ` [PATCH 2/2] memory: atmel-ebi: " Krzysztof Kozlowski
2021-04-23 12:02 ` [Linux-stm32] [PATCH 1/2] memory: stm32-fmc2-ebi: " Christophe Kerello
2021-05-11 12:49 ` Krzysztof Kozlowski

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