* [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned
@ 2018-01-09 16:28 sean.wang
2018-01-09 16:28 ` [PATCH 2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call sean.wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: sean.wang @ 2018-01-09 16:28 UTC (permalink / raw)
To: linus.walleij, linux-mediatek, dan.carpenter, matthias.bgg
Cc: linux-arm-kernel, linux-gpio, linux-kernel, Sean Wang
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(-)
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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call 2018-01-09 16:28 [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned sean.wang @ 2018-01-09 16:28 ` sean.wang 2018-01-10 9:01 ` Matthias Brugger 2018-01-11 9:44 ` Linus Walleij 2018-01-10 9:00 ` [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned Matthias Brugger 2018-01-11 9:42 ` Linus Walleij 2 siblings, 2 replies; 6+ messages in thread From: sean.wang @ 2018-01-09 16:28 UTC (permalink / raw) To: linus.walleij, linux-mediatek, dan.carpenter, matthias.bgg Cc: linux-arm-kernel, linux-gpio, linux-kernel, Sean Wang From: Sean Wang <sean.wang@mediatek.com> Make consistent error handling of all mtk_hw_get_value occurrences using propagating error code from the internal instead of creating a new one. Signed-off-by: Sean Wang <sean.wang@mediatek.com> --- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c index dc32e3c..06e8406 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c @@ -1160,7 +1160,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, case PIN_CONFIG_OUTPUT_ENABLE: err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val); if (err) - return -EINVAL; + return err; /* HW takes input mode as zero; output mode as non-zero */ if ((val && param == PIN_CONFIG_INPUT_ENABLE) || @@ -1184,11 +1184,11 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, case PIN_CONFIG_DRIVE_STRENGTH: err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E4, &val); if (err) - return -EINVAL; + return err; err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E8, &val2); if (err) - return -EINVAL; + return err; /* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1) * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1) @@ -1203,7 +1203,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, err = mtk_hw_get_value(hw, pin, reg, &val); if (err) - return -EINVAL; + return err; ret = val; -- 2.7.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call 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 1 sibling, 0 replies; 6+ messages in thread From: Matthias Brugger @ 2018-01-10 9:01 UTC (permalink / raw) To: sean.wang, linus.walleij, linux-mediatek, dan.carpenter Cc: linux-arm-kernel, linux-gpio, linux-kernel On 01/09/2018 05:28 PM, sean.wang@mediatek.com wrote: > From: Sean Wang <sean.wang@mediatek.com> > > Make consistent error handling of all mtk_hw_get_value occurrences using > propagating error code from the internal instead of creating a new one. > > Signed-off-by: Sean Wang <sean.wang@mediatek.com> > --> drivers/pinctrl/mediatek/pinctrl-mt7622.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 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 dc32e3c..06e8406 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c > @@ -1160,7 +1160,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > case PIN_CONFIG_OUTPUT_ENABLE: > err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val); > if (err) > - return -EINVAL; > + return err; > > /* HW takes input mode as zero; output mode as non-zero */ > if ((val && param == PIN_CONFIG_INPUT_ENABLE) || > @@ -1184,11 +1184,11 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > case PIN_CONFIG_DRIVE_STRENGTH: > err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E4, &val); > if (err) > - return -EINVAL; > + return err; > > err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E8, &val2); > if (err) > - return -EINVAL; > + return err; > > /* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1) > * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1) > @@ -1203,7 +1203,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > > err = mtk_hw_get_value(hw, pin, reg, &val); > if (err) > - return -EINVAL; > + return err; > > ret = val; > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call 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 1 sibling, 0 replies; 6+ messages in thread From: Linus Walleij @ 2018-01-11 9:44 UTC (permalink / raw) To: sean.wang Cc: moderated list:ARM/Mediatek SoC support, Dan Carpenter, Matthias Brugger, Linux ARM, linux-gpio, linux-kernel@vger.kernel.org On Tue, Jan 9, 2018 at 5:28 PM, <sean.wang@mediatek.com> wrote: > From: Sean Wang <sean.wang@mediatek.com> > > Make consistent error handling of all mtk_hw_get_value occurrences using > propagating error code from the internal instead of creating a new one. > > Signed-off-by: Sean Wang <sean.wang@mediatek.com> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned 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:00 ` Matthias Brugger 2018-01-11 9:42 ` Linus Walleij 2 siblings, 0 replies; 6+ messages in thread From: Matthias Brugger @ 2018-01-10 9:00 UTC (permalink / raw) To: sean.wang, linus.walleij, linux-mediatek, dan.carpenter Cc: linux-arm-kernel, linux-gpio, linux-kernel 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; > } > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned 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:00 ` [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned Matthias Brugger @ 2018-01-11 9:42 ` Linus Walleij 2 siblings, 0 replies; 6+ messages in thread From: Linus Walleij @ 2018-01-11 9:42 UTC (permalink / raw) To: sean.wang Cc: moderated list:ARM/Mediatek SoC support, Dan Carpenter, Matthias Brugger, Linux ARM, linux-gpio, linux-kernel@vger.kernel.org On Tue, Jan 9, 2018 at 5: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: Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-11 9:44 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned Matthias Brugger 2018-01-11 9:42 ` Linus Walleij
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).