From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: Colin King <colin.king@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
John Crispin <blogic@openwrt.org>,
devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups
Date: Sun, 11 Nov 2018 07:55:18 +0000 [thread overview]
Message-ID: <20181111075518.GA23361@camaron> (raw)
In-Reply-To: <20181110232806.14255-1-colin.king@canonical.com>
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
WARNING: multiple messages have this Message-ID (diff)
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: Colin King <colin.king@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
John Crispin <blogic@openwrt.org>,
devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups
Date: Sun, 11 Nov 2018 08:55:18 +0100 [thread overview]
Message-ID: <20181111075518.GA23361@camaron> (raw)
In-Reply-To: <20181110232806.14255-1-colin.king@canonical.com>
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
next prev parent reply other threads:[~2018-11-11 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-10 23:28 [PATCH] staging: mt7621-pinctrl: fix uninitialized variable ngroups Colin King
2018-11-11 7:55 ` Sergio Paracuellos [this message]
2018-11-11 7:55 ` Sergio Paracuellos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181111075518.GA23361@camaron \
--to=sergio.paracuellos@gmail.com \
--cc=blogic@openwrt.org \
--cc=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.