Skip to content

Commit

Permalink
staging: mt7621-pinctrl: fix uninitialized variable ngroups
Browse files Browse the repository at this point in the history
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: e12a1a6 ("staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Colin Ian King authored and Greg Kroah-Hartman committed Nov 11, 2018
1 parent 8561fb3 commit cd56a51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit cd56a51

Please sign in to comment.