summaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2025-02-13 17:56:46 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 14:01:22 +0100
commita7052afa9eae2239e25943baa8817a6a56e8aa68 (patch)
tree7b556023a4c60a02c6226142b547d6ba014fdf4c /drivers/gpio
parent9a0a411f591ee6d3d02b73574e37bffdad256472 (diff)
downloadlinux-a7052afa9eae2239e25943baa8817a6a56e8aa68.tar.gz
linux-a7052afa9eae2239e25943baa8817a6a56e8aa68.tar.bz2
linux-a7052afa9eae2239e25943baa8817a6a56e8aa68.zip
gpiolib: Fix crash on error in gpiochip_get_ngpios()
[ Upstream commit 7b4aebeecbbd5b5fe73e35fad3f62ed21aa7ef44 ] 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 <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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 44372f8647d5..1e8f0bdb6ae3 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -905,13 +905,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;
}