[PATCH] soc: samsung: exynos-pmu: Fix uninitialized ret in tensor_set_bits_atomic()

Krzysztof Kozlowski posted 1 patch 1 year, 1 month ago
drivers/soc/samsung/exynos-pmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] soc: samsung: exynos-pmu: Fix uninitialized ret in tensor_set_bits_atomic()
Posted by Krzysztof Kozlowski 1 year, 1 month ago
If tensor_set_bits_atomic() is called with a mask of 0 the function will
just iterate over its bit, not perform any updates and return stack
value of 'ret'.

Also reported by smatch:

  drivers/soc/samsung/exynos-pmu.c:129 tensor_set_bits_atomic() error: uninitialized symbol 'ret'.

Fixes: 0b7c6075022c ("soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/samsung/exynos-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index d8c53cec7f37..dd5256e5aae1 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -126,7 +126,7 @@ static int tensor_set_bits_atomic(void *ctx, unsigned int offset, u32 val,
 		if (ret)
 			return ret;
 	}
-	return ret;
+	return 0;
 }
 
 static bool tensor_is_atomic(unsigned int reg)
-- 
2.43.0
Re: [PATCH] soc: samsung: exynos-pmu: Fix uninitialized ret in tensor_set_bits_atomic()
Posted by Krzysztof Kozlowski 1 year, 1 month ago
On Sat, 04 Jan 2025 14:56:05 +0100, Krzysztof Kozlowski wrote:
> If tensor_set_bits_atomic() is called with a mask of 0 the function will
> just iterate over its bit, not perform any updates and return stack
> value of 'ret'.
> 
> Also reported by smatch:
> 
>   drivers/soc/samsung/exynos-pmu.c:129 tensor_set_bits_atomic() error: uninitialized symbol 'ret'.
> 
> [...]

Applied, thanks!

[1/1] soc: samsung: exynos-pmu: Fix uninitialized ret in tensor_set_bits_atomic()
      https://git.kernel.org/krzk/linux/c/eca836dfd8386b32f1aae60f8e323218ac6a0b75

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