* [PATCH V2] pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
@ 2012-04-23 17:01 John Crispin
[not found] ` <1335200518-3640-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: John Crispin @ 2012-04-23 17:01 UTC (permalink / raw)
To: Linus Walleij; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng
pinmux_map_to_setting() uses setting->data.mux.func/group to store the return
code of pinmux_func_name_to_selector/pinctrl_get_group_selector(). However,
struct pinctrl_setting_mux defines these elements as unsigned, resulting in all
error codes getting lost. The conditionals following the assignments will always
evaluate to false thus breaking the error paths.
This bug can be triggered by loading a pinmux group map from the devicetree
with an invalid function/group string.
Signed-off-by: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Dong Aisheng <dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
drivers/pinctrl/pinmux.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index c494c37..1056e68 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -328,10 +328,10 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
return -EINVAL;
}
- setting->data.mux.func =
- pinmux_func_name_to_selector(pctldev, map->data.mux.function);
- if (setting->data.mux.func < 0)
- return setting->data.mux.func;
+ ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
+ if (ret < 0)
+ return ret;
+ setting->data.mux.func = ret;
ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
&groups, &num_groups);
@@ -355,9 +355,10 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
group = groups[0];
}
- setting->data.mux.group = pinctrl_get_group_selector(pctldev, group);
- if (setting->data.mux.group < 0)
- return setting->data.mux.group;
+ ret = pinctrl_get_group_selector(pctldev, group);
+ if (ret < 0)
+ return ret;
+ setting->data.mux.group = ret;
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins,
&num_pins);
--
1.7.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
[not found] ` <1335200518-3640-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
@ 2012-04-23 17:23 ` Stephen Warren
2012-04-24 5:34 ` Dong Aisheng
2012-04-24 13:16 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Warren @ 2012-04-23 17:23 UTC (permalink / raw)
To: John Crispin; +Cc: Dong Aisheng, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On 04/23/2012 11:01 AM, John Crispin wrote:
> pinmux_map_to_setting() uses setting->data.mux.func/group to store the return
> code of pinmux_func_name_to_selector/pinctrl_get_group_selector(). However,
> struct pinctrl_setting_mux defines these elements as unsigned, resulting in all
> error codes getting lost. The conditionals following the assignments will always
> evaluate to false thus breaking the error paths.
>
> This bug can be triggered by loading a pinmux group map from the devicetree
> with an invalid function/group string.
>
> Signed-off-by: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
> Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Cc: Dong Aisheng <dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Acked-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
[not found] ` <1335200518-3640-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2012-04-23 17:23 ` Stephen Warren
@ 2012-04-24 5:34 ` Dong Aisheng
2012-04-24 13:16 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Dong Aisheng @ 2012-04-24 5:34 UTC (permalink / raw)
To: John Crispin; +Cc: Dong Aisheng, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Mon, Apr 23, 2012 at 07:01:58PM +0200, John Crispin wrote:
> pinmux_map_to_setting() uses setting->data.mux.func/group to store the return
> code of pinmux_func_name_to_selector/pinctrl_get_group_selector(). However,
> struct pinctrl_setting_mux defines these elements as unsigned, resulting in all
> error codes getting lost. The conditionals following the assignments will always
> evaluate to false thus breaking the error paths.
>
> This bug can be triggered by loading a pinmux group map from the devicetree
> with an invalid function/group string.
>
> Signed-off-by: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
> Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Cc: Dong Aisheng <dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> drivers/pinctrl/pinmux.c | 15 ++++++++-------
> 1 files changed, 8 insertions(+), 7 deletions(-)
>
Nice fix.
Acked-by: Dong Aisheng <dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Regards
Dong Aisheng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
[not found] ` <1335200518-3640-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2012-04-23 17:23 ` Stephen Warren
2012-04-24 5:34 ` Dong Aisheng
@ 2012-04-24 13:16 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2012-04-24 13:16 UTC (permalink / raw)
To: John Crispin; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng
On Mon, Apr 23, 2012 at 7:01 PM, John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org> wrote:
> pinmux_map_to_setting() uses setting->data.mux.func/group to store the return
> code of pinmux_func_name_to_selector/pinctrl_get_group_selector(). However,
> struct pinctrl_setting_mux defines these elements as unsigned, resulting in all
> error codes getting lost. The conditionals following the assignments will always
> evaluate to false thus breaking the error paths.
>
> This bug can be triggered by loading a pinmux group map from the devicetree
> with an invalid function/group string.
>
> Signed-off-by: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
> Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Cc: Dong Aisheng <dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Applied with Stephen and Dong's ACKs, thanks!
New contributors to pinctrl, I love this :-)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-24 13:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-23 17:01 [PATCH V2] pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting John Crispin
[not found] ` <1335200518-3640-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2012-04-23 17:23 ` Stephen Warren
2012-04-24 5:34 ` Dong Aisheng
2012-04-24 13:16 ` Linus Walleij
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).