memory: stm32_omm: Fix error handling bugs
Subsystems (3)
cover memory: stm32_omm: Fix error handling bugs
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(-)
Signature · 1 line
2.47.2
PATCH 1/2 memory: stm32_omm: Fix error handling in stm32_omm_configure()
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.
--- drivers/memory/stm32_omm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/memory/stm32_omm.c +5 -2
@@ -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 );
Signature · 1 line
2.47.2
PATCH 2/2 memory: stm32_omm: Fix NULL vs IS_ERR() check in probe()
In reply to Dan CarpenterThe platform_get_resource_byname() function returns NULL on error. It doesn't return error pointers. Update the check to match.
--- drivers/memory/stm32_omm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/memory/stm32_omm.c +2 -2
@@ -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) {
Signature · 1 line
2.47.2
Krzysztof Kozlowski
AppliedQuoted 8 lines · Dan Carpenter
These are a couple bugs which were detected using the Smatch static checker.
Dan Carpenter (2):
memory:stm32_omm: Fix error handling instm32_omm_configure()
memory:stm32_omm: Fix NULL vsIS_ERR()check inprobe()[...]
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,
Signature · 1 line
Krzysztof Kozlowski <[email protected]>