linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Michal Simek <michal.simek@xilinx.com>,
	linux-kernel@vger.kernel.org, monstr@monstr.eu, git@xilinx.com,
	Linus Walleij <linus.walleij@linaro.org>
Cc: dan.carpenter@oracle.com, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] pinctrl: core: Set ret to 0 when group is skipped
Date: Fri, 12 Mar 2021 09:25:03 +0000	[thread overview]
Message-ID: <ced576c2-11a3-3fbf-0fdf-4620a442cadf@canonical.com> (raw)
In-Reply-To: <e5203bae68eb94b4b8b4e67e5e7b4d86bb989724.1615534291.git.michal.simek@xilinx.com>

On 12/03/2021 07:31, Michal Simek wrote:
> Static analyzer tool found that the ret variable is not initialized but
> code expects ret value >=0 when pinconf is skipped in the first pinmux
> loop. The same expectation is for pinmux in a pinconf loop.
> That's why initialize ret to 0 to avoid uninitialized ret value in first
> loop or reusing ret value from first loop in second.
> 
> Addresses-Coverity: ("Uninitialized variables")
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> CC: Colin Ian King <colin.king@canonical.com>
> CC: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> 
>  drivers/pinctrl/core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index f5c32d2a3c91..136c323d855e 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -1266,6 +1266,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
>  			break;
>  		case PIN_MAP_TYPE_CONFIGS_PIN:
>  		case PIN_MAP_TYPE_CONFIGS_GROUP:
> +			ret = 0;
>  			break;
>  		default:
>  			ret = -EINVAL;
> @@ -1284,6 +1285,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
>  	list_for_each_entry(setting, &state->settings, node) {
>  		switch (setting->type) {
>  		case PIN_MAP_TYPE_MUX_GROUP:
> +			ret = 0;
>  			break;
>  		case PIN_MAP_TYPE_CONFIGS_PIN:
>  		case PIN_MAP_TYPE_CONFIGS_GROUP:
> 

Thanks Michal,

Reviewed-by: Colin Ian King <colin.king@canonical.com>

  reply	other threads:[~2021-03-12  9:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12  7:31 [PATCH] pinctrl: core: Set ret to 0 when group is skipped Michal Simek
2021-03-12  9:25 ` Colin Ian King [this message]
2021-03-15 15:38 ` Linus Walleij

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=ced576c2-11a3-3fbf-0fdf-4620a442cadf@canonical.com \
    --to=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=git@xilinx.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=monstr@monstr.eu \
    /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 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).