From: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
To: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Dong Aisheng
<dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH] pinctrl: fix signed vs unsigned conditional inside pinmux_map_to_setting
Date: Mon, 23 Apr 2012 10:12:23 +0200 [thread overview]
Message-ID: <1335168743-3868-1-git-send-email-blogic@openwrt.org> (raw)
pinmux_map_to_settingi() uses setting->data.mux.func to store the return code of
pinmux_func_name_to_selector(). However, struct pinctrl_setting_mux defines the
func element as unsigned, resulting in all error codes getting lost. The
conditional following the assignment will always evaluate to false thus breaking
the error path.
This bug can be triggered by loading a pinmux group map from the devicetree
with an invalid function 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 | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index c494c37..cd377a2 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);
--
1.7.9.1
next reply other threads:[~2012-04-23 8:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 8:12 John Crispin [this message]
[not found] ` <1335168743-3868-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2012-04-23 15:52 ` [PATCH] pinctrl: fix signed vs unsigned conditional inside pinmux_map_to_setting Stephen Warren
[not found] ` <4F957ADA.9000203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-23 15:59 ` John Crispin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335168743-3868-1-git-send-email-blogic@openwrt.org \
--to=blogic-p3rkhjxn3npafugrpc6u6w@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=dong.aisheng-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox