Skip to content

Commit 7b4aebe

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpiolib: Fix crash on error in gpiochip_get_ngpios()
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: 55b2395 ("gpio: mmio: handle "ngpios" properly in bgpio_init()") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250213155646.2882324-1-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent b9644fb commit 7b4aebe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpio/gpiolib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,13 @@ int gpiochip_get_ngpios(struct gpio_chip *gc, struct device *dev)
904904
}
905905

906906
if (gc->ngpio == 0) {
907-
chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
907+
dev_err(dev, "tried to insert a GPIO chip with zero lines\n");
908908
return -EINVAL;
909909
}
910910

911911
if (gc->ngpio > FASTPATH_NGPIO)
912-
chip_warn(gc, "line cnt %u is greater than fast path cnt %u\n",
913-
gc->ngpio, FASTPATH_NGPIO);
912+
dev_warn(dev, "line cnt %u is greater than fast path cnt %u\n",
913+
gc->ngpio, FASTPATH_NGPIO);
914914

915915
return 0;
916916
}

0 commit comments

Comments
 (0)