| From 5297c693d8c8e08fa742e3112cf70723f7a04da2 Mon Sep 17 00:00:00 2001 |
| From: Florian Fainelli <f.fainelli@gmail.com> |
| Date: Thu, 27 Jan 2022 13:50:31 -0800 |
| Subject: pinctrl: bcm2835: Fix a few error paths |
| |
| From: Florian Fainelli <f.fainelli@gmail.com> |
| |
| commit 5297c693d8c8e08fa742e3112cf70723f7a04da2 upstream. |
| |
| After commit 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio |
| hogs") a few error paths would not unwind properly the registration of |
| gpio ranges. Correct that by assigning a single error label and goto it |
| whenever we encounter a fatal error. |
| |
| Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") |
| Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> |
| Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com |
| Signed-off-by: Linus Walleij <linus.walleij@linaro.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 +++++++++++++++-------- |
| 1 file changed, 15 insertions(+), 8 deletions(-) |
| |
| --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c |
| +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c |
| @@ -1264,16 +1264,18 @@ static int bcm2835_pinctrl_probe(struct |
| sizeof(*girq->parents), |
| GFP_KERNEL); |
| if (!girq->parents) { |
| - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); |
| - return -ENOMEM; |
| + err = -ENOMEM; |
| + goto out_remove; |
| } |
| |
| if (is_7211) { |
| pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS, |
| sizeof(*pc->wake_irq), |
| GFP_KERNEL); |
| - if (!pc->wake_irq) |
| - return -ENOMEM; |
| + if (!pc->wake_irq) { |
| + err = -ENOMEM; |
| + goto out_remove; |
| + } |
| } |
| |
| /* |
| @@ -1297,8 +1299,10 @@ static int bcm2835_pinctrl_probe(struct |
| |
| len = strlen(dev_name(pc->dev)) + 16; |
| name = devm_kzalloc(pc->dev, len, GFP_KERNEL); |
| - if (!name) |
| - return -ENOMEM; |
| + if (!name) { |
| + err = -ENOMEM; |
| + goto out_remove; |
| + } |
| |
| snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); |
| |
| @@ -1317,11 +1321,14 @@ static int bcm2835_pinctrl_probe(struct |
| err = gpiochip_add_data(&pc->gpio_chip, pc); |
| if (err) { |
| dev_err(dev, "could not add GPIO chip\n"); |
| - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); |
| - return err; |
| + goto out_remove; |
| } |
| |
| return 0; |
| + |
| +out_remove: |
| + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); |
| + return err; |
| } |
| |
| static struct platform_driver bcm2835_pinctrl_driver = { |