aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinmux.c
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2012-04-23 13:01:58 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-04-24 09:09:50 -0400
commit15f70e1b9a1a6351c252cb8892272cc4601818c7 (patch)
tree97d38f59d412ca6f001f0674652958f0790466a9 /drivers/pinctrl/pinmux.c
parentdcb5dbc305b975cccf40942feba40964069541d3 (diff)
pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
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@openwrt.org> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r--drivers/pinctrl/pinmux.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index fa0357bd88ff..7cd0c7d0f2cf 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -329,10 +329,10 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
329 return -EINVAL; 329 return -EINVAL;
330 } 330 }
331 331
332 setting->data.mux.func = 332 ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
333 pinmux_func_name_to_selector(pctldev, map->data.mux.function); 333 if (ret < 0)
334 if (setting->data.mux.func < 0) 334 return ret;
335 return setting->data.mux.func; 335 setting->data.mux.func = ret;
336 336
337 ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, 337 ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
338 &groups, &num_groups); 338 &groups, &num_groups);
@@ -356,9 +356,10 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
356 group = groups[0]; 356 group = groups[0];
357 } 357 }
358 358
359 setting->data.mux.group = pinctrl_get_group_selector(pctldev, group); 359 ret = pinctrl_get_group_selector(pctldev, group);
360 if (setting->data.mux.group < 0) 360 if (ret < 0)
361 return setting->data.mux.group; 361 return ret;
362 setting->data.mux.group = ret;
362 363
363 ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, 364 ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins,
364 &num_pins); 365 &num_pins);