Skip to contentSkip to conversation

soc: qcom: initialize local variable

PATCH Applied [email protected] 3 participants 3 messages Aug 19, 2020 – Nov 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: qcom: initialize local variable

From: Tom Rix <[email protected]>

clang static analysis reports this problem

pdr_interface.c:596:6: warning: Branch condition evaluates
to a garbage value

        if (!req.service_path[0])
            ^~~~~~~~~~~~~~~~~~~~

This check that req.service_path was set in an earlier loop. However req is a stack variable and its initial value is undefined.

So initialize req to 0.

Fixes fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
---
 drivers/soc/qcom/pdr_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pdr_interface.c +1 -1
index 088dc99f77f3..f63135c09667 100644
@@ -569,7 +569,7 @@ EXPORT_SYMBOL(pdr_add_lookup);
 int pdr_restart_pd(struct pdr_handle *pdr, struct pdr_service *pds)
 {
 	struct servreg_restart_pd_resp resp;
-	struct servreg_restart_pd_req req;
+	struct servreg_restart_pd_req req = { 0 };
 	struct sockaddr_qrtr addr;
 	struct pdr_service *tmp;
 	struct qmi_txn txn;
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On 2020-08-20 00:16, [email protected] wrote:

From: Tom Rix <[email protected]>

clang static analysis reports this problem

pdr_interface.c:596:6: warning: Branch condition evaluates
to a garbage value

        if (!req.service_path[0])
            ^~~~~~~~~~~~~~~~~~~~
Quoted 8 lines

This check that req.service_path was set in an earlier loop. However req is a stack variable and its initial value is undefined.

So initialize req to 0.

Fixes fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")

Tom,
Thanks for the patch.

Quoted 18 lines
---
 drivers/soc/qcom/pdr_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pdr_interface.c +1 -1
index 088dc99f77f3..f63135c09667 100644
@@ -569,7 +569,7 @@ EXPORT_SYMBOL(pdr_add_lookup);
 int pdr_restart_pd(struct pdr_handle *pdr, struct pdr_service *pds)
 {
 	struct servreg_restart_pd_resp resp;
-	struct servreg_restart_pd_req req;
+	struct servreg_restart_pd_req req = { 0 };
 	struct sockaddr_qrtr addr;
 	struct pdr_service *tmp;
 	struct qmi_txn txn;
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project.
#2 lore raw
In reply to [email protected]
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 10 lines · On Wed, 19 Aug 2020 11:46:37 -0700 you wrote:

From: Tom Rix <[email protected]>

clang static analysis reports this problem

pdr_interface.c:596:6: warning: Branch condition evaluates
to a garbage value

        if (!req.service_path[0])
            ^~~~~~~~~~~~~~~~~~~~

[...]

Here is the summary with links:
- soc: qcom: initialize local variable

    https://git.kernel.org/qcom/c/a161ffe4b877

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html