Skip to content

Commit 52ce7b0

Browse files
andy-shevmehmetb0
authored andcommitted
gpiolib: Fix crash on error in gpiochip_get_ngpios()
BugLink: https://bugs.launchpad.net/bugs/2104873 [ Upstream commit 7b4aebe ] 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 406a7de commit 52ce7b0

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
@@ -902,13 +902,13 @@ int gpiochip_get_ngpios(struct gpio_chip *gc, struct device *dev)
902902
}
903903

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

909909
if (gc->ngpio > FASTPATH_NGPIO)
910-
chip_warn(gc, "line cnt %u is greater than fast path cnt %u\n",
911-
gc->ngpio, FASTPATH_NGPIO);
910+
dev_warn(dev, "line cnt %u is greater than fast path cnt %u\n",
911+
gc->ngpio, FASTPATH_NGPIO);
912912

913913
return 0;
914914
}

0 commit comments

Comments
 (0)