* [PATCH] pinctrl: core: Set ret to 0 when group is skipped
@ 2021-03-12 7:31 Michal Simek
2021-03-12 9:25 ` Colin Ian King
2021-03-15 15:38 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Michal Simek @ 2021-03-12 7:31 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git, Linus Walleij
Cc: colin.king, dan.carpenter, linux-gpio
Static analyzer tool found that the ret variable is not initialized but
code expects ret value >=0 when pinconf is skipped in the first pinmux
loop. The same expectation is for pinmux in a pinconf loop.
That's why initialize ret to 0 to avoid uninitialized ret value in first
loop or reusing ret value from first loop in second.
Addresses-Coverity: ("Uninitialized variables")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
CC: Colin Ian King <colin.king@canonical.com>
CC: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/pinctrl/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index f5c32d2a3c91..136c323d855e 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1266,6 +1266,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
break;
case PIN_MAP_TYPE_CONFIGS_PIN:
case PIN_MAP_TYPE_CONFIGS_GROUP:
+ ret = 0;
break;
default:
ret = -EINVAL;
@@ -1284,6 +1285,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
list_for_each_entry(setting, &state->settings, node) {
switch (setting->type) {
case PIN_MAP_TYPE_MUX_GROUP:
+ ret = 0;
break;
case PIN_MAP_TYPE_CONFIGS_PIN:
case PIN_MAP_TYPE_CONFIGS_GROUP:
--
2.30.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: core: Set ret to 0 when group is skipped
2021-03-12 7:31 [PATCH] pinctrl: core: Set ret to 0 when group is skipped Michal Simek
@ 2021-03-12 9:25 ` Colin Ian King
2021-03-15 15:38 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2021-03-12 9:25 UTC (permalink / raw)
To: Michal Simek, linux-kernel, monstr, git, Linus Walleij
Cc: dan.carpenter, linux-gpio
On 12/03/2021 07:31, Michal Simek wrote:
> Static analyzer tool found that the ret variable is not initialized but
> code expects ret value >=0 when pinconf is skipped in the first pinmux
> loop. The same expectation is for pinmux in a pinconf loop.
> That's why initialize ret to 0 to avoid uninitialized ret value in first
> loop or reusing ret value from first loop in second.
>
> Addresses-Coverity: ("Uninitialized variables")
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> CC: Colin Ian King <colin.king@canonical.com>
> CC: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>
> drivers/pinctrl/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index f5c32d2a3c91..136c323d855e 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -1266,6 +1266,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
> break;
> case PIN_MAP_TYPE_CONFIGS_PIN:
> case PIN_MAP_TYPE_CONFIGS_GROUP:
> + ret = 0;
> break;
> default:
> ret = -EINVAL;
> @@ -1284,6 +1285,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
> list_for_each_entry(setting, &state->settings, node) {
> switch (setting->type) {
> case PIN_MAP_TYPE_MUX_GROUP:
> + ret = 0;
> break;
> case PIN_MAP_TYPE_CONFIGS_PIN:
> case PIN_MAP_TYPE_CONFIGS_GROUP:
>
Thanks Michal,
Reviewed-by: Colin Ian King <colin.king@canonical.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: core: Set ret to 0 when group is skipped
2021-03-12 7:31 [PATCH] pinctrl: core: Set ret to 0 when group is skipped Michal Simek
2021-03-12 9:25 ` Colin Ian King
@ 2021-03-15 15:38 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-03-15 15:38 UTC (permalink / raw)
To: Michal Simek
Cc: linux-kernel, Michal Simek, git, Colin King, Dan Carpenter,
open list:GPIO SUBSYSTEM
On Fri, Mar 12, 2021 at 8:31 AM Michal Simek <michal.simek@xilinx.com> wrote:
> Static analyzer tool found that the ret variable is not initialized but
> code expects ret value >=0 when pinconf is skipped in the first pinmux
> loop. The same expectation is for pinmux in a pinconf loop.
> That's why initialize ret to 0 to avoid uninitialized ret value in first
> loop or reusing ret value from first loop in second.
>
> Addresses-Coverity: ("Uninitialized variables")
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> CC: Colin Ian King <colin.king@canonical.com>
> CC: Dan Carpenter <dan.carpenter@oracle.com>
Patch applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-15 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 7:31 [PATCH] pinctrl: core: Set ret to 0 when group is skipped Michal Simek
2021-03-12 9:25 ` Colin Ian King
2021-03-15 15:38 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.