pinctrl: at91: use devm_kasprintf() to avoid potential leaks
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Fri, 3 Feb 2023 13:27:14 +0000 (15:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:54 +0000 (09:39 +0100)
[ Upstream commit 1c4e5c470a56f7f7c649c0c70e603abc1eab15c4 ]

Use devm_kasprintf() instead of kasprintf() to avoid any potential
leaks. At the moment drivers have no remove functionality thus
there is no need for fixes tag.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20230203132714.1931596-1-claudiu.beznea@microchip.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/pinctrl-at91-pio4.c
drivers/pinctrl/pinctrl-at91.c

index 03c32b2c5d303315733acc1abb3e779f21d65bee..c86fcdfaf825c28476a6cfbc443479844b4a1e8f 100644 (file)
@@ -1126,8 +1126,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
 
                pin_desc[i].number = i;
                /* Pin naming convention: P(bank_name)(bank_pin_number). */
-               pin_desc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
-                                            bank + 'A', line);
+               pin_desc[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "P%c%d",
+                                                 bank + 'A', line);
 
                group->name = group_names[i] = pin_desc[i].name;
                group->pin = pin_desc[i].number;
index 6022496bb6a98854be2d194fd6454f36543d2f25..3b0341c730ee0c2d1a05511fc75722b5414c4145 100644 (file)
@@ -1891,7 +1891,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
        }
 
        for (i = 0; i < chip->ngpio; i++)
-               names[i] = kasprintf(GFP_KERNEL, "pio%c%d", alias_idx + 'A', i);
+               names[i] = devm_kasprintf(&pdev->dev, GFP_KERNEL, "pio%c%d", alias_idx + 'A', i);
 
        chip->names = (const char *const *)names;