* [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux
@ 2018-10-10 15:13 Gustavo A. R. Silva
2018-10-10 16:08 ` Charles Keepax
2018-10-11 8:40 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-10 15:13 UTC (permalink / raw)
To: Charles Keepax, Richard Fitzgerald, Linus Walleij
Cc: alsa-devel, patches, linux-gpio, linux-kernel, Gustavo A. R. Silva
There is a potential execution path in which variable *ret* is checked
in an IF statement, and then its value is used to report an error at
line 659 without being properly initialized previously:
659 if (ret)
660 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret);
Fix this by initializing variable *ret* to 0 in order to
avoid unpredictable or unintended results.
Addresses-Coverity-ID: 1471969 ("Uninitialized scalar variable")
Fixes: 218d72a77b0b ("pinctrl: madera: Add driver for Cirrus Logic Madera codecs")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
- Initialize variable ret to 0 instead of -1. Thanks to Charles Keepax
for pointing this out.
- Update subject and commit log.
drivers/pinctrl/cirrus/pinctrl-madera-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/cirrus/pinctrl-madera-core.c b/drivers/pinctrl/cirrus/pinctrl-madera-core.c
index 0266302..a5dda83 100644
--- a/drivers/pinctrl/cirrus/pinctrl-madera-core.c
+++ b/drivers/pinctrl/cirrus/pinctrl-madera-core.c
@@ -608,7 +608,7 @@ static int madera_mux_set_mux(struct pinctrl_dev *pctldev,
unsigned int n_chip_groups = priv->chip->n_pin_groups;
const char *func_name = madera_mux_funcs[selector].name;
unsigned int reg;
- int i, ret;
+ int i, ret = 0;
dev_dbg(priv->dev, "%s selecting %u (%s) for group %u (%s)\n",
__func__, selector, func_name, group,
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux
2018-10-10 15:13 [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux Gustavo A. R. Silva
@ 2018-10-10 16:08 ` Charles Keepax
2018-10-11 8:40 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2018-10-10 16:08 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Richard Fitzgerald, Linus Walleij, alsa-devel, patches,
linux-gpio, linux-kernel
On Wed, Oct 10, 2018 at 05:13:13PM +0200, Gustavo A. R. Silva wrote:
> There is a potential execution path in which variable *ret* is checked
> in an IF statement, and then its value is used to report an error at
> line 659 without being properly initialized previously:
>
> 659 if (ret)
> 660 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret);
>
> Fix this by initializing variable *ret* to 0 in order to
> avoid unpredictable or unintended results.
>
> Addresses-Coverity-ID: 1471969 ("Uninitialized scalar variable")
> Fixes: 218d72a77b0b ("pinctrl: madera: Add driver for Cirrus Logic Madera codecs")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux
2018-10-10 15:13 [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux Gustavo A. R. Silva
2018-10-10 16:08 ` Charles Keepax
@ 2018-10-11 8:40 ` Linus Walleij
2018-10-12 9:04 ` Gustavo A. R. Silva
1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2018-10-11 8:40 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Charles Keepax, Richard Fitzgerald,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
patches, open list:GPIO SUBSYSTEM, linux-kernel
On Wed, Oct 10, 2018 at 5:13 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> There is a potential execution path in which variable *ret* is checked
> in an IF statement, and then its value is used to report an error at
> line 659 without being properly initialized previously:
>
> 659 if (ret)
> 660 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret);
>
> Fix this by initializing variable *ret* to 0 in order to
> avoid unpredictable or unintended results.
>
> Addresses-Coverity-ID: 1471969 ("Uninitialized scalar variable")
> Fixes: 218d72a77b0b ("pinctrl: madera: Add driver for Cirrus Logic Madera codecs")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
> - Initialize variable ret to 0 instead of -1. Thanks to Charles Keepax
> for pointing this out.
> - Update subject and commit log.
Patch applied with Charles' ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux
2018-10-11 8:40 ` Linus Walleij
@ 2018-10-12 9:04 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-12 9:04 UTC (permalink / raw)
To: Linus Walleij
Cc: Charles Keepax, Richard Fitzgerald,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
patches, open list:GPIO SUBSYSTEM, linux-kernel
On 10/11/18 10:40 AM, Linus Walleij wrote:
>> Changes in v2:
>> - Initialize variable ret to 0 instead of -1. Thanks to Charles Keepax
>> for pointing this out.
>> - Update subject and commit log.
>
> Patch applied with Charles' ACK.
>
Thanks, Linus.
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-12 9:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 15:13 [PATCH v2] pinctrl: madera: Fix uninitialized variable bug in madera_mux_set_mux Gustavo A. R. Silva
2018-10-10 16:08 ` Charles Keepax
2018-10-11 8:40 ` Linus Walleij
2018-10-12 9:04 ` Gustavo A. R. Silva
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).