]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
pinctrl: nuvoton: check for devm_kasprintf() failure
authorNicholas Mc Guire <hofrat@osadl.org>
Fri, 23 Nov 2018 16:12:58 +0000 (17:12 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 5 Dec 2018 21:55:04 +0000 (22:55 +0100)
devm_kasprintf() may return NULL on failure of internal allocation thus
the assignment to  .label  is not safe if not checked. On error
npcm7xx_gpio_of() returns negative values so -ENOMEM in the
(unlikely) failure case of devm_kasprintf() should be fine here.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c

index b455209382a5f923d887be2efec16c674bd9e336..17f909d8b63a90e3cdd312788bc94a944148f208 100644 (file)
@@ -1925,6 +1925,9 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
                        pctrl->gpio_bank[id].gc.label =
                                devm_kasprintf(pctrl->dev, GFP_KERNEL, "%pOF",
                                               np);
+                       if (pctrl->gpio_bank[id].gc.label == NULL)
+                               return -ENOMEM;
+
                        pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
                        pctrl->gpio_bank[id].direction_input =
                                pctrl->gpio_bank[id].gc.direction_input;