]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: mvebu: fail probe if gpiochip registration fails
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Wed, 24 Jun 2026 13:16:45 +0000 (21:16 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Fri, 26 Jun 2026 09:50:46 +0000 (11:50 +0200)
mvebu_gpio_probe() registers the GPIO chip with
devm_gpiochip_add_data() but ignores the return value. If registration
fails, probe continues and leaves later code operating on a GPIO chip
that was never published to gpiolib.

Return the registration error so the device fails probe cleanly.

Fixes: fefe7b092345 ("gpio: introduce gpio-mvebu driver for Marvell SoCs")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260624131645.86884-1-pengpeng@iscas.ac.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpio-mvebu.c

index c030d1f00abcaed2941f4e3459253789f5bce1fc..689dc6354c2d78f897f4f9c5c4d1d2d5de7d9f8f 100644 (file)
@@ -1221,7 +1221,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
                BUG();
        }
 
-       devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
+       err = devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
+       if (err)
+               return dev_err_probe(&pdev->dev, err,
+                                    "failed to register gpiochip\n");
 
        /* Some MVEBU SoCs have simple PWM support for GPIO lines */
        if (IS_REACHABLE(CONFIG_PWM)) {