Skip to content

Commit fd482f2

Browse files
ffainelligregkh
authored andcommitted
pinctrl: bcm2835: Fix a few error paths
commit 5297c69 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 752d9ea commit fd482f2

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
@@ -1264,16 +1264,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
12641264
sizeof(*girq->parents),
12651265
GFP_KERNEL);
12661266
if (!girq->parents) {
1267-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1268-
return -ENOMEM;
1267+
err = -ENOMEM;
1268+
goto out_remove;
12691269
}
12701270

12711271
if (is_7211) {
12721272
pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
12731273
sizeof(*pc->wake_irq),
12741274
GFP_KERNEL);
1275-
if (!pc->wake_irq)
1276-
return -ENOMEM;
1275+
if (!pc->wake_irq) {
1276+
err = -ENOMEM;
1277+
goto out_remove;
1278+
}
12771279
}
12781280

12791281
/*
@@ -1297,8 +1299,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
12971299

12981300
len = strlen(dev_name(pc->dev)) + 16;
12991301
name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
1300-
if (!name)
1301-
return -ENOMEM;
1302+
if (!name) {
1303+
err = -ENOMEM;
1304+
goto out_remove;
1305+
}
13021306

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

@@ -1317,11 +1321,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
13171321
err = gpiochip_add_data(&pc->gpio_chip, pc);
13181322
if (err) {
13191323
dev_err(dev, "could not add GPIO chip\n");
1320-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1321-
return err;
1324+
goto out_remove;
13221325
}
13231326

13241327
return 0;
1328+
1329+
out_remove:
1330+
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1331+
return err;
13251332
}
13261333

13271334
static struct platform_driver bcm2835_pinctrl_driver = {

0 commit comments

Comments
 (0)