summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/pinctrl-single.c
diff options
context:
space:
mode:
authorAxel Haslam <ahaslam@baylibre.com>2016-11-09 15:54:00 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-11-11 21:28:07 +0100
commitde7416bcee3f7c9004fff92795a03a46f3f40316 (patch)
tree3b89455382d1802e86fd245cfd26f1b2802e33d5 /drivers/pinctrl/pinctrl-single.c
parent95bdb0ea3668d86513376e0e88e88f5c0202acba (diff)
pinctrl: single: check for any error when getting rows
pinctrl_count_index_with_args returns -ENOENT not -EINVAL. The return check would pass, and we would try to kzalloc with a negative error size throwing a warning. Instead of checking for -EINVAL specifically, lets check for any error and avoid negative size allocations. Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-single.c')
-rw-r--r--drivers/pinctrl/pinctrl-single.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 539f31cd8e00..f36a9f1f3949 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1133,8 +1133,10 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
struct pcs_function *function;
rows = pinctrl_count_index_with_args(np, name);
- if (rows == -EINVAL)
- return rows;
+ if (rows <= 0) {
+ dev_err(pcs->dev, "Ivalid number of rows: %d\n", rows);
+ return -EINVAL;
+ }
vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
if (!vals)
@@ -1228,8 +1230,10 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
struct pcs_function *function;
rows = pinctrl_count_index_with_args(np, name);
- if (rows == -EINVAL)
- return rows;
+ if (rows <= 0) {
+ dev_err(pcs->dev, "Invalid number of rows: %d\n", rows);
+ return -EINVAL;
+ }
npins_in_row = pcs->width / pcs->bits_per_pin;