diff options
author | Michael Riesch <michael.riesch@wolfvision.net> | 2022-09-05 12:07:17 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-13 12:07:55 +0200 |
commit | 6553d2c2a5e3cf2f5a3e480eb959cfe2a4983421 (patch) | |
tree | a984a75f1662fa9757bb5d7b5fb64dec3e989928 /drivers | |
parent | bc475fd88810f8fbb4b6f786d0a772b09f215d9d (diff) | |
download | barebox-6553d2c2a5e3cf2f5a3e480eb959cfe2a4983421.tar.gz barebox-6553d2c2a5e3cf2f5a3e480eb959cfe2a4983421.tar.xz |
of: overlay: avoid potential null pointer exception
The function of_overlay_fix_path returns NULL in certain error cases but
of_overlay_apply_symbols (which is the only caller) does not check the
return value. For broken overlays this may result in a null pointer
exception. Fix this by checking the return value and inform the user
what exactly went wrong.
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Link: https://lore.barebox.org/20220905100717.150557-3-michael.riesch@wolfvision.net
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/overlay.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 20686db511..884cdf8928 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -102,8 +102,10 @@ static char *of_overlay_fix_path(struct device_node *root, if (of_get_child_by_name(fragment, "__overlay__")) break; } - if (!fragment) + if (!fragment) { + pr_info("could not find __overlay__ node\n"); return NULL; + } target = find_target(root, fragment); if (!target) @@ -143,6 +145,8 @@ static int of_overlay_apply_symbols(struct device_node *root, old_path = of_property_get_value(prop); new_path = of_overlay_fix_path(root, overlay, old_path); + if (!new_path) + return -EINVAL; pr_debug("add symbol %s with new path %s\n", prop->name, new_path); |