gpio: shared: fix a NULL-pointer dereference
PATCH 1/1 gpio: shared: fix a NULL-pointer dereference
From: Bartosz Golaszewski <[email protected]>
The fact that CONFIG_OF is enabled does not mean that the device tree is populated and that of_root points to a valid device node. Check if it's NULL before trying to traverse the tree.
--- drivers/gpio/gpiolib-shared.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-shared.c +4 -1
@@ -205,7 +205,10 @@ static int gpio_shared_of_traverse(struct device_node *curr)static int gpio_shared_of_scan (void ) { -return gpio_shared_of_traverse (of_root); +if (of_root) +return gpio_shared_of_traverse (of_root); + +return 0 ; }#else static int gpio_shared_of_scan (void )
Signature · 1 line
2.51.0
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The fact that
CONFIG_OFis enabled does not mean that the device tree is populated and thatof_rootpoints to a valid device node. Check if it's NULL before trying to traverse the tree.
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 5 lines · Bartosz Golaszewski
The fact that
CONFIG_OFis enabled does not mean that the device tree is populated and thatof_rootpoints to a valid device node. Check if it's NULL before trying to traverse the tree.
Applied, thanks!
[1/1] gpio: shared: fix a NULL-pointer dereference
https://git.kernel.org/brgl/linux/c/01be9047988d15850ca15d146c5f4aeb5de2f569
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>