Commit 181cdac0 authored by Sean Wang's avatar Sean Wang Committed by Linus Walleij

pinctrl: mediatek: mt7622: fix potential uninitialized value being returned

commit d6ed9355 ("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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent fb36a7b0
...@@ -1412,9 +1412,11 @@ static struct pinctrl_desc mtk_desc = { ...@@ -1412,9 +1412,11 @@ static struct pinctrl_desc mtk_desc = {
static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio) static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
{ {
struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent); 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; return !!value;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment