* [PATCH 0/2] MediaTek pinctrl cleanups and improvements
@ 2023-01-18 6:20 Guodong Liu
2023-01-18 6:20 ` [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero Guodong Liu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Guodong Liu @ 2023-01-18 6:20 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger, Light Hsieh,
Rob Herring, AngeloGioacchino Del Regno
Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Zhiyong Tao, Guodong Liu
Patch 1. Fix coverity by initializing pullen and pullup as zero.
Coverity error message:
This issue is detected by
Checker: UNINIT
Type: Uninitialized scalar variable
Defect is in:
File: drivers/pinctrl/mediatek/pinctrl-paris.c
Function and lines:
mtk_pctrl_show_one_pin:627
CID 10350517 (#1 of 2): Uninitialized scalar variable (UNINIT)
(7) uninit_use: Using uninitialized value pullen.
rsel = pullen;
pullen = 1;
} else {
CID 10350553 (#1 of 1): Uninitialized scalar variable (UNINIT)
(8) uninit_use_in_call: Using uninitialized value pullup when
calling scnprintf.
len += scnprintf(buf + len, buf_len - len,
"%03d: %1d%1d%1d%1d%02d%1d%1d%1d%1d",
gpio,
pinmux,
mtk_pctrl_get_direction(hw, gpio),
mtk_pctrl_get_out(hw, gpio),
mtk_pctrl_get_in(hw, gpio),
mtk_pctrl_get_driving(hw, gpio),
mtk_pctrl_get_smt(hw, gpio),
mtk_pctrl_get_ies(hw, gpio),
pullen,
pullup);
Patch 2. Fix coverity by initializing *buf as zero.
Coverity error message:
This issue is detected by
Checker: UNINIT
Type: Uninitialized scalar variable
Defect is in:
File: drivers/pinctrl/mediatek/pinctrl-paris.c
Function and lines:
mtk_pctrl_dbg_show
static void mtk_pctrl_dbg_show(struct pinctrl_dev *pctldev,
struct seq_file *s,
unsigned int gpio)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
(1) var_decl: Declaring variable buf without initializer.
char buf[PIN_DBG_BUF_SZ];
(void)mtk_pctrl_show_one_pin(hw, gpio, buf, PIN_DBG_BUF_SZ);
CID 10801732 (#1 of 1): Uninitialized scalar variable (UNINIT)
(2) uninit_use_in_call: Using uninitialized value *buf as argument to %s
when calling seq_printf.
seq_printf(s, "%s", buf);
Guodong Liu (2):
pinctrl: mediatek: Initialize variable pullen and pullup to zero
pinctrl: mediatek: Initialize variable *buf to zero
drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero
2023-01-18 6:20 [PATCH 0/2] MediaTek pinctrl cleanups and improvements Guodong Liu
@ 2023-01-18 6:20 ` Guodong Liu
2023-01-18 11:26 ` AngeloGioacchino Del Regno
2023-01-18 6:20 ` [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf " Guodong Liu
2023-01-26 13:40 ` [PATCH 0/2] MediaTek pinctrl cleanups and improvements Linus Walleij
2 siblings, 1 reply; 6+ messages in thread
From: Guodong Liu @ 2023-01-18 6:20 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger, Light Hsieh,
Rob Herring, AngeloGioacchino Del Regno
Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Zhiyong Tao, Guodong Liu
Coverity spotted that pullen and pullup is not initialized to zero in
mtk_pctrl_show_one_pin. The uninitialized variable pullen is used in
assignment statement "rsel = pullen;" in mtk_pctrl_show_one_pin, and
Uninitialized variable pullup is used when calling scnprintf. Fix this
coverity by initializing pullen and pullup as zero.
Fixes: 184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration
dump via debugfs.")
Signed-off-by: Guodong Liu <Guodong.Liu@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index f2ce3f626dd1..e736c1610f3c 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -635,7 +635,7 @@ static int mtk_hw_get_value_wrap(struct mtk_pinctrl *hw, unsigned int gpio, int
ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
unsigned int gpio, char *buf, unsigned int buf_len)
{
- int pinmux, pullup, pullen, len = 0, r1 = -1, r0 = -1, rsel = -1;
+ int pinmux, pullup = 0, pullen = 0, len = 0, r1 = -1, r0 = -1, rsel = -1;
const struct mtk_pin_desc *desc;
u32 try_all_type = 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf to zero
2023-01-18 6:20 [PATCH 0/2] MediaTek pinctrl cleanups and improvements Guodong Liu
2023-01-18 6:20 ` [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero Guodong Liu
@ 2023-01-18 6:20 ` Guodong Liu
2023-01-18 11:26 ` AngeloGioacchino Del Regno
2023-01-26 13:40 ` [PATCH 0/2] MediaTek pinctrl cleanups and improvements Linus Walleij
2 siblings, 1 reply; 6+ messages in thread
From: Guodong Liu @ 2023-01-18 6:20 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger, Light Hsieh,
Rob Herring, AngeloGioacchino Del Regno
Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Zhiyong Tao, Guodong Liu
Coverity spotted that *buf is not initialized to zero in
mtk_pctrl_dbg_show. Using uninitialized variable *buf as argument to %s
when calling seq_printf. Fix this coverity by initializing *buf as zero.
Fixes: 184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration
dump via debugfs.")
Signed-off-by: Guodong Liu <Guodong.Liu@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index e736c1610f3c..d2fbfffda038 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -714,7 +714,7 @@ static void mtk_pctrl_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
unsigned int gpio)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
- char buf[PIN_DBG_BUF_SZ];
+ char buf[PIN_DBG_BUF_SZ] = { 0 };
(void)mtk_pctrl_show_one_pin(hw, gpio, buf, PIN_DBG_BUF_SZ);
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf to zero
2023-01-18 6:20 ` [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf " Guodong Liu
@ 2023-01-18 11:26 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-18 11:26 UTC (permalink / raw)
To: Guodong Liu, Sean Wang, Linus Walleij, Matthias Brugger,
Light Hsieh, Rob Herring
Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Zhiyong Tao
Il 18/01/23 07:20, Guodong Liu ha scritto:
> Coverity spotted that *buf is not initialized to zero in
> mtk_pctrl_dbg_show. Using uninitialized variable *buf as argument to %s
> when calling seq_printf. Fix this coverity by initializing *buf as zero.
>
> Fixes: 184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration
> dump via debugfs.")
> Signed-off-by: Guodong Liu <Guodong.Liu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero
2023-01-18 6:20 ` [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero Guodong Liu
@ 2023-01-18 11:26 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-18 11:26 UTC (permalink / raw)
To: Guodong Liu, Sean Wang, Linus Walleij, Matthias Brugger,
Light Hsieh, Rob Herring
Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Zhiyong Tao
Il 18/01/23 07:20, Guodong Liu ha scritto:
> Coverity spotted that pullen and pullup is not initialized to zero in
> mtk_pctrl_show_one_pin. The uninitialized variable pullen is used in
> assignment statement "rsel = pullen;" in mtk_pctrl_show_one_pin, and
> Uninitialized variable pullup is used when calling scnprintf. Fix this
> coverity by initializing pullen and pullup as zero.
>
> Fixes: 184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration
> dump via debugfs.")
> Signed-off-by: Guodong Liu <Guodong.Liu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] MediaTek pinctrl cleanups and improvements
2023-01-18 6:20 [PATCH 0/2] MediaTek pinctrl cleanups and improvements Guodong Liu
2023-01-18 6:20 ` [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero Guodong Liu
2023-01-18 6:20 ` [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf " Guodong Liu
@ 2023-01-26 13:40 ` Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2023-01-26 13:40 UTC (permalink / raw)
To: Guodong Liu
Cc: Sean Wang, Matthias Brugger, Light Hsieh, Rob Herring,
AngeloGioacchino Del Regno, linux-mediatek, linux-gpio,
linux-kernel, linux-arm-kernel, Zhiyong Tao
On Wed, Jan 18, 2023 at 7:20 AM Guodong Liu <Guodong.Liu@mediatek.com> wrote:
> Guodong Liu (2):
> pinctrl: mediatek: Initialize variable pullen and pullup to zero
> pinctrl: mediatek: Initialize variable *buf to zero
Patches applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-26 13:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 6:20 [PATCH 0/2] MediaTek pinctrl cleanups and improvements Guodong Liu
2023-01-18 6:20 ` [PATCH 1/2] pinctrl: mediatek: Initialize variable pullen and pullup to zero Guodong Liu
2023-01-18 11:26 ` AngeloGioacchino Del Regno
2023-01-18 6:20 ` [PATCH 2/2] pinctrl: mediatek: Initialize variable *buf " Guodong Liu
2023-01-18 11:26 ` AngeloGioacchino Del Regno
2023-01-26 13:40 ` [PATCH 0/2] MediaTek pinctrl cleanups and improvements Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox