linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] memory: stm32_omm: Fix error handling bugs
@ 2025-05-09 11:04 Dan Carpenter
  2025-05-09 11:04 ` [PATCH 1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure() Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-05-09 11:04 UTC (permalink / raw)
  To: Patrice Chotard
  Cc: Alexandre Torgue, Christophe Kerello, Krzysztof Kozlowski,
	linux-arm-kernel, linux-kernel, linux-stm32, Maxime Coquelin,
	Philipp Zabel

These are a couple bugs which were detected using the Smatch static
checker.

Dan Carpenter (2):
  memory: stm32_omm: Fix error handling in stm32_omm_configure()
  memory: stm32_omm: Fix NULL vs IS_ERR() check in probe()

 drivers/memory/stm32_omm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

-- 
2.47.2



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

* [PATCH 1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure()
  2025-05-09 11:04 [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Dan Carpenter
@ 2025-05-09 11:04 ` Dan Carpenter
  2025-05-09 11:04 ` [PATCH 2/2] memory: stm32_omm: Fix NULL vs IS_ERR() check in probe() Dan Carpenter
  2025-05-12  6:38 ` [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-05-09 11:04 UTC (permalink / raw)
  To: Patrice Chotard
  Cc: Krzysztof Kozlowski, Maxime Coquelin, Alexandre Torgue,
	Philipp Zabel, Christophe Kerello, linux-kernel, linux-stm32,
	linux-arm-kernel

There are two error handling bugs in the stm32_omm_configure() function.
1) The error code needs to be set if clk_get_rate() fails.
2) If devm_reset_control_get_exclusive() then call
   pm_runtime_put_sync_suspend() before returning.

Fixes: 8181d061dcff ("memory: Add STM32 Octo Memory Manager driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/memory/stm32_omm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/stm32_omm.c b/drivers/memory/stm32_omm.c
index 166baed0738a..fa0f75e4a6e8 100644
--- a/drivers/memory/stm32_omm.c
+++ b/drivers/memory/stm32_omm.c
@@ -222,6 +222,7 @@ static int stm32_omm_configure(struct device *dev)
 		clk_rate = clk_get_rate(omm->clk_bulk[i].clk);
 		if (!clk_rate) {
 			dev_err(dev, "Invalid clock rate\n");
+			ret = -EINVAL;
 			goto error;
 		}
 
@@ -230,8 +231,10 @@ static int stm32_omm_configure(struct device *dev)
 	}
 
 	rstc = devm_reset_control_get_exclusive(dev, "omm");
-	if (IS_ERR(rstc))
-		return dev_err_probe(dev, PTR_ERR(rstc), "reset get failed\n");
+	if (IS_ERR(rstc)) {
+		ret = dev_err_probe(dev, PTR_ERR(rstc), "reset get failed\n");
+		goto error;
+	}
 
 	reset_control_assert(rstc);
 	udelay(2);
-- 
2.47.2



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

* [PATCH 2/2] memory: stm32_omm: Fix NULL vs IS_ERR() check in probe()
  2025-05-09 11:04 [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Dan Carpenter
  2025-05-09 11:04 ` [PATCH 1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure() Dan Carpenter
@ 2025-05-09 11:04 ` Dan Carpenter
  2025-05-12  6:38 ` [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-05-09 11:04 UTC (permalink / raw)
  To: Patrice Chotard
  Cc: Krzysztof Kozlowski, Maxime Coquelin, Alexandre Torgue,
	Christophe Kerello, linux-kernel, linux-stm32, linux-arm-kernel

The platform_get_resource_byname() function returns NULL on error.  It
doesn't return error pointers.  Update the check to match.

Fixes: 8181d061dcff ("memory: Add STM32 Octo Memory Manager driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/memory/stm32_omm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/stm32_omm.c b/drivers/memory/stm32_omm.c
index fa0f75e4a6e8..c8de785401f2 100644
--- a/drivers/memory/stm32_omm.c
+++ b/drivers/memory/stm32_omm.c
@@ -320,8 +320,8 @@ static int stm32_omm_probe(struct platform_device *pdev)
 		return PTR_ERR(omm->io_base);
 
 	omm->mm_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory_map");
-	if (IS_ERR(omm->mm_res))
-		return PTR_ERR(omm->mm_res);
+	if (!omm->mm_res)
+		return -ENODEV;
 
 	/* check child's access */
 	for_each_child_of_node_scoped(dev->of_node, child) {
-- 
2.47.2



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

* Re: [PATCH 0/2] memory: stm32_omm: Fix error handling bugs
  2025-05-09 11:04 [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Dan Carpenter
  2025-05-09 11:04 ` [PATCH 1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure() Dan Carpenter
  2025-05-09 11:04 ` [PATCH 2/2] memory: stm32_omm: Fix NULL vs IS_ERR() check in probe() Dan Carpenter
@ 2025-05-12  6:38 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-12  6:38 UTC (permalink / raw)
  To: Patrice Chotard, Dan Carpenter
  Cc: Alexandre Torgue, Christophe Kerello, Krzysztof Kozlowski,
	linux-arm-kernel, linux-kernel, linux-stm32, Maxime Coquelin,
	Philipp Zabel


On Fri, 09 May 2025 14:04:19 +0300, Dan Carpenter wrote:
> These are a couple bugs which were detected using the Smatch static
> checker.
> 
> Dan Carpenter (2):
>   memory: stm32_omm: Fix error handling in stm32_omm_configure()
>   memory: stm32_omm: Fix NULL vs IS_ERR() check in probe()
> 
> [...]

Applied, thanks!

[1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure()
      https://git.kernel.org/krzk/linux-mem-ctrl/c/d44eeb20d9bedce11297a09628ba5dd39db236be
[2/2] memory: stm32_omm: Fix NULL vs IS_ERR() check in probe()
      https://git.kernel.org/krzk/linux-mem-ctrl/c/0169a24036848cf18205301673259bb6879eef97

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>



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

end of thread, other threads:[~2025-05-12  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 11:04 [PATCH 0/2] memory: stm32_omm: Fix error handling bugs Dan Carpenter
2025-05-09 11:04 ` [PATCH 1/2] memory: stm32_omm: Fix error handling in stm32_omm_configure() Dan Carpenter
2025-05-09 11:04 ` [PATCH 2/2] memory: stm32_omm: Fix NULL vs IS_ERR() check in probe() Dan Carpenter
2025-05-12  6:38 ` [PATCH 0/2] memory: stm32_omm: Fix error handling bugs 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).