Skip to contentSkip to conversation

gpiolib: check for parent device in devprop_gpiochip_set_names()

PATCH In review Bartosz Golaszewski 2 participants 2 messages Sep 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpiolib: check for parent device in devprop_gpiochip_set_names()

From: Bartosz Golaszewski <[email protected]>

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")

---
v1 -> v2:
- added a comment as requested by Andy

 drivers/gpio/gpiolib.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpio/gpiolib.c +4 -0
index b7b608ef9e6b..dfcff5d24b18 100644
@@ -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;
Signature · 1 line
2.26.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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.

Quoted 5 lines
Fixes 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")

FWIW,