Skip to content

Commit

Permalink
pinctrl: at91-pio4: check return value of devm_kasprintf()
Browse files Browse the repository at this point in the history
devm_kasprintf() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).

Fixes: 7761808 ("pinctrl: introduce driver for Atmel PIO4 controller")
Depends-on: 1c4e5c4 ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks")
Depends-on: 5a8f9cf ("pinctrl: at91-pio4: use proper format specifier for unsigned int")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230615105333.585304-4-claudiu.beznea@microchip.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Claudiu Beznea authored and Linus Walleij committed Jun 16, 2023
1 parent 310cd4c commit f6fd5d4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/pinctrl/pinctrl-at91-pio4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
/* Pin naming convention: P(bank_name)(bank_pin_number). */
pin_desc[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "P%c%u",
bank + 'A', line);
if (!pin_desc[i].name)
return -ENOMEM;

group->name = group_names[i] = pin_desc[i].name;
group->pin = pin_desc[i].number;
Expand Down

0 comments on commit f6fd5d4

Please sign in to comment.