gpiolib: Fix crash on error in gpiochip_get_ngpios()
PATCH 1/1 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.
--- drivers/gpio/gpiolib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +3 -3
@@ -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 ; }
Signature · 1 line
2.45.1.3035.g276e886db78b
From: Bartosz Golaszewski <[email protected]>
Quoted 8 lines · Andy Shevchenko
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 viabgpio_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.[...]
Eeek! Good catch, queued for fixes.
Bart
[1/1] gpiolib: Fix crash on error in gpiochip_get_ngpios()
commit: 7b4aebeecbbd5b5fe73e35fad3f62ed21aa7ef44
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>