Skip to content

Commit 0af388f

Browse files
claudiubezneagregkh
authored andcommitted
pinctrl: at91-pio4: check return value of devm_kasprintf()
[ Upstream commit f6fd5d4 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 35404a4 commit 0af388f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/pinctrl/pinctrl-at91-pio4.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
11221122
/* Pin naming convention: P(bank_name)(bank_pin_number). */
11231123
pin_desc[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "P%c%d",
11241124
bank + 'A', line);
1125+
if (!pin_desc[i].name)
1126+
return -ENOMEM;
11251127

11261128
group->name = group_names[i] = pin_desc[i].name;
11271129
group->pin = pin_desc[i].number;

0 commit comments

Comments
 (0)