gpiolib: check for parent device in devprop_gpiochip_set_names()
Subsystems (2)
PATCH 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.
--- drivers/gpio/gpiolib.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpio/gpiolib.c +3 -0
@@ -375,6 +375,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)int ret, i;int count; +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
Quoted 6 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.
Ah, nice!
Can we also add a small comment in the code, b/c w/o it I would stumble over and eager to remove looks-as-unneeded check?
Quoted 24 lines
Fixes 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")Reported-by Anders Roxell <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpiolib.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpio/gpiolib.c +3
-0@@ -375,6 +375,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)int ret, i;int count; +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
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
Quoted 6 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 4 lines
Ah, nice!
Can we also add a small comment in the code, b/c w/o it I would stumble over and eager to remove looks-as-unneeded check?Reviewed-by Andy Shevchenko <[email protected]>
Sure, I'll make a v2 then.
Bart
Anders Roxell
Tested-byQuoted 12 lines · Bartosz Golaszewski
Quoted 9 lines · Andy Shevchenko
Quoted 6 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 4 lines
Quoted 4 lines
Ah, nice!
Can we also add a small comment in the code, b/c w/o it I would stumble over and eager to remove looks-as-unneeded check?Reviewed-by Andy Shevchenko <[email protected]>