Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965075AbeAJJA4 (ORCPT + 1 other); Wed, 10 Jan 2018 04:00:56 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:42677 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964862AbeAJJAx (ORCPT ); Wed, 10 Jan 2018 04:00:53 -0500 X-Google-Smtp-Source: ACJfBovVQCLGCjdgXWIKBwq64Y+xhWYtHV6emAE7jE4ah/vnu5TPyqn29c0VtQcxs9xyTiV8UO1kwQ== Subject: Re: [PATCH 1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned 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 References: From: Matthias Brugger Message-ID: <99978b09-cc80-d2cd-7d72-0b34380f6130@gmail.com> Date: Wed, 10 Jan 2018 10:00:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/09/2018 05:28 PM, sean.wang@mediatek.com wrote: > From: Sean Wang > > 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 > Signed-off-by: Sean Wang > --- > drivers/pinctrl/mediatek/pinctrl-mt7622.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > Reviewed-by: Matthias Brugger > 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; > } >