linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: initialize local variable
@ 2020-08-19 18:46 trix
  2020-08-25  7:27 ` Sibi Sankar
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2020-08-19 18:46 UTC (permalink / raw)
  To: agross, bjorn.andersson, sibis; +Cc: linux-arm-msm, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

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

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/soc/qcom/pdr_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c
index 088dc99f77f3..f63135c09667 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -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;
-- 
2.18.1


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

* Re: [PATCH] soc: qcom: initialize local variable
  2020-08-19 18:46 [PATCH] soc: qcom: initialize local variable trix
@ 2020-08-25  7:27 ` Sibi Sankar
  0 siblings, 0 replies; 2+ messages in thread
From: Sibi Sankar @ 2020-08-25  7:27 UTC (permalink / raw)
  To: trix
  Cc: agross, bjorn.andersson, linux-arm-msm, linux-kernel, linux-kernel-owner

On 2020-08-20 00:16, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> 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")
> 

Tom,
Thanks for the patch.

Reviewed-by: Sibi Sankar <sibis@codeaurora.org>

> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/soc/qcom/pdr_interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/pdr_interface.c 
> b/drivers/soc/qcom/pdr_interface.c
> index 088dc99f77f3..f63135c09667 100644
> --- a/drivers/soc/qcom/pdr_interface.c
> +++ b/drivers/soc/qcom/pdr_interface.c
> @@ -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;

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project.

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

end of thread, other threads:[~2020-08-25  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 18:46 [PATCH] soc: qcom: initialize local variable trix
2020-08-25  7:27 ` Sibi Sankar

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