mediatek: backport upstream mediatek patches
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0194-pinctrl-mediatek-mt7622-fix-potential-uninitialized-.patch
1 From cfcb2cc358f3ff466d4c419d8f6fe0263bdc47b1 Mon Sep 17 00:00:00 2001
2 From: Sean Wang <sean.wang@mediatek.com>
3 Date: Wed, 10 Jan 2018 00:28:24 +0800
4 Subject: [PATCH 194/224] pinctrl: mediatek: mt7622: fix potential
5 uninitialized value being returned
6
7 commit d6ed93551320 ("pinctrl: mediatek: add pinctrl driver for MT7622
8 SoC") leads to the following static checker warning:
9
10 drivers/pinctrl/mediatek/pinctrl-mt7622.c:1419 mtk_gpio_get()
11 error: uninitialized symbol 'value'.
12 1412 static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
13 1413 {
14 1414 struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
15 1415 int value;
16 1416
17 1417 mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
18 ^^^^^^^^^^^^^^^^
19 1418
20 1419 return !!value;
21 1420 }
22
23 The appropriate error handling must be added to avoid the potential error
24 caused by uninitialized value being returned.
25
26 Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
27 Signed-off-by: Sean Wang <sean.wang@mediatek.com>
28 Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
29 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
30 ---
31 drivers/pinctrl/mediatek/pinctrl-mt7622.c | 6 ++++--
32 1 file changed, 4 insertions(+), 2 deletions(-)
33
34 diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
35 index 3824d82888ac..dc32e3c3bd73 100644
36 --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
37 +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
38 @@ -1412,9 +1412,11 @@ static struct pinctrl_desc mtk_desc = {
39 static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
40 {
41 struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
42 - int value;
43 + int value, err;
44
45 - mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
46 + err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
47 + if (err)
48 + return err;
49
50 return !!value;
51 }
52 --
53 2.11.0
54