* [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb
@ 2020-03-16 20:48 Nathan Chancellor
2020-03-16 20:59 ` Nick Desaulniers
2020-03-16 22:09 ` Bjorn Andersson
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2020-03-16 20:48 UTC (permalink / raw
To: Bjorn Andersson, Andy Gross
Cc: Sibi Sankar, linux-arm-msm, linux-kernel, clang-built-linux,
Nathan Chancellor
Clang warns:
../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is
used uninitialized whenever 'for' loop exits because its condition is
false [-Wsometimes-uninitialized]
list_for_each_entry(pds, &pdr->lookups, node) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/list.h:624:7: note: expanded from macro
'list_for_each_entry'
&pos->member != (head);
^~~~~~~~~~~~~~~~~~~~~~
../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use
occurs here
if (!found)
^~~~~
../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if
it is always true
list_for_each_entry(pds, &pdr->lookups, node) {
^
../include/linux/list.h:624:7: note: expanded from macro
'list_for_each_entry'
&pos->member != (head);
^
../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the
variable 'found' to silence this warning
bool found;
^
= 0
1 warning generated.
Initialize found to false to fix this warning.
Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
Link: https://github.com/ClangBuiltLinux/linux/issues/933
Signed-off-by: Nathan Chancellor <natechancellor@gmail.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 7ee088b9cc7c..17ad3b8698e1 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,
const struct servreg_state_updated_ind *ind_msg = data;
struct pdr_list_node *ind;
struct pdr_service *pds;
- bool found;
+ bool found = false;
if (!ind_msg || !ind_msg->service_path[0] ||
strlen(ind_msg->service_path) > SERVREG_NAME_LENGTH)
--
2.26.0.rc1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb
2020-03-16 20:48 [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb Nathan Chancellor
@ 2020-03-16 20:59 ` Nick Desaulniers
2020-03-16 22:09 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-03-16 20:59 UTC (permalink / raw
To: Nathan Chancellor
Cc: Bjorn Andersson, Andy Gross, Sibi Sankar, linux-arm-msm, LKML,
clang-built-linux
On Mon, Mar 16, 2020 at 1:49 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> ../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is
> used uninitialized whenever 'for' loop exits because its condition is
> false [-Wsometimes-uninitialized]
> list_for_each_entry(pds, &pdr->lookups, node) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../include/linux/list.h:624:7: note: expanded from macro
> 'list_for_each_entry'
> &pos->member != (head);
> ^~~~~~~~~~~~~~~~~~~~~~
> ../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use
> occurs here
> if (!found)
> ^~~~~
> ../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if
> it is always true
> list_for_each_entry(pds, &pdr->lookups, node) {
> ^
> ../include/linux/list.h:624:7: note: expanded from macro
> 'list_for_each_entry'
> &pos->member != (head);
> ^
> ../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the
> variable 'found' to silence this warning
> bool found;
> ^
> = 0
> 1 warning generated.
>
> Initialize found to false to fix this warning.
>
> Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
> Link: https://github.com/ClangBuiltLinux/linux/issues/933
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Yep, thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.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 7ee088b9cc7c..17ad3b8698e1 100644
> --- a/drivers/soc/qcom/pdr_interface.c
> +++ b/drivers/soc/qcom/pdr_interface.c
> @@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,
> const struct servreg_state_updated_ind *ind_msg = data;
> struct pdr_list_node *ind;
> struct pdr_service *pds;
> - bool found;
> + bool found = false;
>
> if (!ind_msg || !ind_msg->service_path[0] ||
> strlen(ind_msg->service_path) > SERVREG_NAME_LENGTH)
> --
> 2.26.0.rc1
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200316204855.15611-1-natechancellor%40gmail.com.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb
2020-03-16 20:48 [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb Nathan Chancellor
2020-03-16 20:59 ` Nick Desaulniers
@ 2020-03-16 22:09 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2020-03-16 22:09 UTC (permalink / raw
To: Nathan Chancellor
Cc: Andy Gross, Sibi Sankar, linux-arm-msm, linux-kernel,
clang-built-linux
On Mon 16 Mar 13:48 PDT 2020, Nathan Chancellor wrote:
> Clang warns:
>
> ../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is
> used uninitialized whenever 'for' loop exits because its condition is
> false [-Wsometimes-uninitialized]
> list_for_each_entry(pds, &pdr->lookups, node) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../include/linux/list.h:624:7: note: expanded from macro
> 'list_for_each_entry'
> &pos->member != (head);
> ^~~~~~~~~~~~~~~~~~~~~~
> ../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use
> occurs here
> if (!found)
> ^~~~~
> ../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if
> it is always true
> list_for_each_entry(pds, &pdr->lookups, node) {
> ^
> ../include/linux/list.h:624:7: note: expanded from macro
> 'list_for_each_entry'
> &pos->member != (head);
> ^
> ../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the
> variable 'found' to silence this warning
> bool found;
> ^
> = 0
> 1 warning generated.
>
> Initialize found to false to fix this warning.
>
> Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
> Link: https://github.com/ClangBuiltLinux/linux/issues/933
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Thanks Nathan, applied with Nick's ack.
Regards,
Bjorn
> ---
> 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 7ee088b9cc7c..17ad3b8698e1 100644
> --- a/drivers/soc/qcom/pdr_interface.c
> +++ b/drivers/soc/qcom/pdr_interface.c
> @@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,
> const struct servreg_state_updated_ind *ind_msg = data;
> struct pdr_list_node *ind;
> struct pdr_service *pds;
> - bool found;
> + bool found = false;
>
> if (!ind_msg || !ind_msg->service_path[0] ||
> strlen(ind_msg->service_path) > SERVREG_NAME_LENGTH)
> --
> 2.26.0.rc1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-16 22:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-16 20:48 [PATCH] soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb Nathan Chancellor
2020-03-16 20:59 ` Nick Desaulniers
2020-03-16 22:09 ` Bjorn Andersson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.