pinctrl: mediatek: moore: handle mtk_hw_set_value() errors in mtk_pinmux_set_mux()
authorKarina Yankevich <k.yankevich@omp.ru>
Fri, 22 Sep 2023 13:59:26 +0000 (16:59 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 27 Sep 2023 08:39:29 +0000 (10:39 +0200)
mtk_pinmux_set_mux() doesn't check the result of mtk_hw_set_value()
despite it may return a negative error code. Propagate error code
to caller functions.

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
Link: https://lore.kernel.org/r/20230922135926.3653428-2-k.yankevich@omp.ru
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/mediatek/pinctrl-moore.c

index 8649a2f9d324d946e1cafacbb847678fcaa04713..889469c7ac26926fd65be2e88942fb1051ce72e9 100644 (file)
@@ -45,7 +45,7 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
        struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
        struct function_desc *func;
        struct group_desc *grp;
-       int i;
+       int i, err;
 
        func = pinmux_generic_get_function(pctldev, selector);
        if (!func)
@@ -67,8 +67,11 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
                if (!desc->name)
                        return -ENOTSUPP;
 
-               mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
-                                pin_modes[i]);
+               err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
+                                      pin_modes[i]);
+
+               if (err)
+                       return err;
        }
 
        return 0;