Skip to content

Commit 5297c69

Browse files
ffainelliLinus Walleij
authored andcommitted
pinctrl: bcm2835: Fix a few error paths
After commit 266423e ("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: 266423e ("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>
1 parent 474932a commit 5297c69

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

drivers/pinctrl/bcm/pinctrl-bcm2835.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,16 +1269,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
12691269
sizeof(*girq->parents),
12701270
GFP_KERNEL);
12711271
if (!girq->parents) {
1272-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1273-
return -ENOMEM;
1272+
err = -ENOMEM;
1273+
goto out_remove;
12741274
}
12751275

12761276
if (is_7211) {
12771277
pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
12781278
sizeof(*pc->wake_irq),
12791279
GFP_KERNEL);
1280-
if (!pc->wake_irq)
1281-
return -ENOMEM;
1280+
if (!pc->wake_irq) {
1281+
err = -ENOMEM;
1282+
goto out_remove;
1283+
}
12821284
}
12831285

12841286
/*
@@ -1306,8 +1308,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
13061308

13071309
len = strlen(dev_name(pc->dev)) + 16;
13081310
name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
1309-
if (!name)
1310-
return -ENOMEM;
1311+
if (!name) {
1312+
err = -ENOMEM;
1313+
goto out_remove;
1314+
}
13111315

13121316
snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i);
13131317

@@ -1326,11 +1330,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
13261330
err = gpiochip_add_data(&pc->gpio_chip, pc);
13271331
if (err) {
13281332
dev_err(dev, "could not add GPIO chip\n");
1329-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1330-
return err;
1333+
goto out_remove;
13311334
}
13321335

13331336
return 0;
1337+
1338+
out_remove:
1339+
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1340+
return err;
13341341
}
13351342

13361343
static struct platform_driver bcm2835_pinctrl_driver = {

0 commit comments

Comments
 (0)