Commit db221412 authored by Nicholas Mc Guire's avatar Nicholas Mc Guire Committed by Geert Uytterhoeven

pinctrl: rza1: Handle devm_kasprintf() failure cases

devm_kasprintf() may return NULL on failure of internal allocation
thus the assignments are not safe if not checked. On error
rza1_pinctrl_register() respectively rza1_parse_gpiochip() return
negative values so -ENOMEM in the (unlikely) failure case of
devm_kasprintf() should be fine here.
Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
Fixes: 5a49b644 ("pinctrl: Renesas RZ/A1 pin and gpio controller")
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent f4caa6ee
...@@ -1225,6 +1225,9 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl, ...@@ -1225,6 +1225,9 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
chip->base = -1; chip->base = -1;
chip->label = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn", chip->label = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn",
np); np);
if (!chip->label)
return -ENOMEM;
chip->ngpio = of_args.args[2]; chip->ngpio = of_args.args[2];
chip->of_node = np; chip->of_node = np;
chip->parent = rza1_pctl->dev; chip->parent = rza1_pctl->dev;
...@@ -1326,6 +1329,8 @@ static int rza1_pinctrl_register(struct rza1_pinctrl *rza1_pctl) ...@@ -1326,6 +1329,8 @@ static int rza1_pinctrl_register(struct rza1_pinctrl *rza1_pctl)
pins[i].number = i; pins[i].number = i;
pins[i].name = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, pins[i].name = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL,
"P%u-%u", port, pin); "P%u-%u", port, pin);
if (!pins[i].name)
return -ENOMEM;
if (i % RZA1_PINS_PER_PORT == 0) { if (i % RZA1_PINS_PER_PORT == 0) {
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment