* [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups
@ 2018-11-10 23:28 Colin King
2018-11-11 7:55 ` Sergio Paracuellos
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-11-10 23:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Sergio Paracuellos, John Crispin, devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the for_each_node_with_property loop us incrementing variable
ngroups however it was not initialized and hence will contain garbage.
Fix this by initializing ngroups to zero.
Detected with static analysis with cppcheck:
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:89]: (error) Uninitialized
variable: ngroups
Fixes: e12a1a6e087b ("staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index b8566ed898f1..aa98fbb17013 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -82,7 +82,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
struct property *prop;
const char *function_name, *group_name;
int ret;
- int ngroups;
+ int ngroups = 0;
unsigned int reserved_maps = 0;
for_each_node_with_property(np_config, "group")
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups
2018-11-10 23:28 [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups Colin King
@ 2018-11-11 7:55 ` Sergio Paracuellos
0 siblings, 0 replies; 2+ messages in thread
From: Sergio Paracuellos @ 2018-11-11 7:55 UTC (permalink / raw)
To: Colin King
Cc: Greg Kroah-Hartman, John Crispin, devel, kernel-janitors, linux-kernel
On Sat, Nov 10, 2018 at 11:28:06PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the for_each_node_with_property loop us incrementing variable
> ngroups however it was not initialized and hence will contain garbage.
> Fix this by initializing ngroups to zero.
>
> Detected with static analysis with cppcheck:
>
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:89]: (error) Uninitialized
> variable: ngroups
>
> Fixes: e12a1a6e087b ("staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> index b8566ed898f1..aa98fbb17013 100644
> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> @@ -82,7 +82,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
> struct property *prop;
> const char *function_name, *group_name;
> int ret;
> - int ngroups;
> + int ngroups = 0;
> unsigned int reserved_maps = 0;
>
> for_each_node_with_property(np_config, "group")
> --
> 2.19.1
>
Thanks, Colin. Looks good.
Reviewed-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Best regards,
Sergio Paracuellos
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-11 7:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-10 23:28 [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups Colin King
2018-11-11 7:55 ` Sergio Paracuellos
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).