提交 de7416bc 编写于 作者: A Axel Haslam 提交者: Linus Walleij

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: NAxel Haslam <ahaslam@baylibre.com>
Acked-by: NTony Lindgren <tony@atomide.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 95bdb0ea
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册