From: Bartosz Golaszewski Date: Thu, 17 Sep 2020 07:48:57 +0000 (+0200) Subject: gpiolib: check for parent device in devprop_gpiochip_set_names() X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=587823d39f85ff9777a862019eca720b97a16a52;p=uclinux-h8%2Flinux.git gpiolib: check for parent device in devprop_gpiochip_set_names() It's possible for a GPIO chip to not have a parent device (whose properties we inspect for 'gpio-line-names'). In this case we should simply return from devprop_gpiochip_set_names(). Add an appropriate check for this use-case. Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Reported-by: Anders Roxell Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Tested-by: Anders Roxell Reviewed-by: Mika Westerberg --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b7b608ef9e6b..dfcff5d24b18 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -375,6 +375,10 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) int ret, i; int count; + /* GPIO chip may not have a parent device whose properties we inspect. */ + if (!dev) + return 0; + count = device_property_string_array_count(dev, "gpio-line-names"); if (count < 0) return 0;