linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: sean.wang@mediatek.com, linus.walleij@linaro.org,
	linux-mediatek@lists.infradead.org, dan.carpenter@oracle.com
Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned
Date: Wed, 10 Jan 2018 10:00:49 +0100	[thread overview]
Message-ID: <99978b09-cc80-d2cd-7d72-0b34380f6130@gmail.com> (raw)
In-Reply-To: <a26c40a8ad2af3cf81b31ae34bc82c1ef80d9279.1515514758.git.sean.wang@mediatek.com>



On 01/09/2018 05:28 PM, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> commit d6ed93551320 ("pinctrl: mediatek: add pinctrl driver for MT7622
> SoC") leads to the following static checker warning:
> 
> drivers/pinctrl/mediatek/pinctrl-mt7622.c:1419 mtk_gpio_get()
> error: uninitialized symbol 'value'.
> 1412  static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> 1413  {
> 1414          struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
> 1415          int value;
> 1416
> 1417          mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
> ^^^^^^^^^^^^^^^^
> 1418
> 1419          return !!value;
> 1420  }
> 
> The appropriate error handling must be added to avoid the potential error
> caused by uninitialized value being returned.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  drivers/pinctrl/mediatek/pinctrl-mt7622.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> index 3824d82..dc32e3c 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> @@ -1412,9 +1412,11 @@ static struct pinctrl_desc mtk_desc = {
>  static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
>  {
>  	struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
> -	int value;
> +	int value, err;
>  
> -	mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
> +	err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
> +	if (err)
> +		return err;
>  
>  	return !!value;
>  }
> 

  parent reply	other threads:[~2018-01-10  9:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 16:28 [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned sean.wang
2018-01-09 16:28 ` [PATCH 2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call sean.wang
2018-01-10  9:01   ` Matthias Brugger
2018-01-11  9:44   ` Linus Walleij
2018-01-10  9:00 ` Matthias Brugger [this message]
2018-01-11  9:42 ` [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned 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=99978b09-cc80-d2cd-7d72-0b34380f6130@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=sean.wang@mediatek.com \
    /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).