Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: microchip-sgpio: check return value of devm_kasprintf()

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: 7e5ea974e61c ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO")
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-3-claudiu.beznea@microchip.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Claudiu Beznea and committed by
Linus Walleij
310cd4c2 9063777c

+3
+3
drivers/pinctrl/pinctrl-microchip-sgpio.c
··· 816 816 pctl_desc->name = devm_kasprintf(dev, GFP_KERNEL, "%s-%sput", 817 817 dev_name(dev), 818 818 bank->is_input ? "in" : "out"); 819 + if (!pctl_desc->name) 820 + return -ENOMEM; 821 + 819 822 pctl_desc->pctlops = &sgpio_pctl_ops; 820 823 pctl_desc->pmxops = &sgpio_pmx_ops; 821 824 pctl_desc->confops = &sgpio_confops;