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>
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)
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;