gpio: shared: fix a NULL-pointer dereference
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.
Fixes: a060b8c511 ("gpiolib: implement low-level, shared GPIO support")
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/dbe20642-9662-40af-a593-c1263baea73b@sirena.org.uk/
Tested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20251118200459.13969-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user