]> Git Repo - linux.git/commitdiff
gpiolib: Fix crash on error in gpiochip_get_ngpios()
authorAndy Shevchenko <[email protected]>
Thu, 13 Feb 2025 15:56:46 +0000 (17:56 +0200)
committerBartosz Golaszewski <[email protected]>
Thu, 13 Feb 2025 17:51:39 +0000 (18:51 +0100)
The gpiochip_get_ngpios() uses chip_*() macros to print messages.
However these macros rely on gpiodev to be initialised and set,
which is not the case when called via bgpio_init(). In such a case
the printing messages will crash on NULL pointer dereference.
Replace chip_*() macros by the respective dev_*() ones to avoid
such crash.

Fixes: 55b2395e4e92 ("gpio: mmio: handle "ngpios" properly in bgpio_init()")
Signed-off-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Bartosz Golaszewski <[email protected]>
drivers/gpio/gpiolib.c

index 679ed764cb143c4b3357106de1570e8d38441372..ca2f58a2cd45e7a8f883fd4c326e1e357c51cbb5 100644 (file)
@@ -904,13 +904,13 @@ int gpiochip_get_ngpios(struct gpio_chip *gc, struct device *dev)
        }
 
        if (gc->ngpio == 0) {
-               chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
+               dev_err(dev, "tried to insert a GPIO chip with zero lines\n");
                return -EINVAL;
        }
 
        if (gc->ngpio > FASTPATH_NGPIO)
-               chip_warn(gc, "line cnt %u is greater than fast path cnt %u\n",
-                       gc->ngpio, FASTPATH_NGPIO);
+               dev_warn(dev, "line cnt %u is greater than fast path cnt %u\n",
+                        gc->ngpio, FASTPATH_NGPIO);
 
        return 0;
 }
This page took 0.057147 seconds and 4 git commands to generate.