aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <[email protected]>2020-07-16 21:27:47 +0300
committerGreg Kroah-Hartman <[email protected]>2020-07-23 17:04:28 +0200
commit29c4a54bc645c8b6745eeb58519e9ad794ceb419 (patch)
tree37ac94175f772e0597749dbbc84828610b7722d4
parentba47d845d715a010f7b51f6f89bae32845e6acb7 (diff)
device property: Avoid NULL pointer dereference in device_get_next_child_node()
When we have no primary fwnode or when it's a software node, we may end up in the situation when fwnode is a NULL pointer. There is no point to look for secondary fwnode in such case. Add a necessary check to a condition. Fixes: 114dbb4fa7c4 ("drivers property: When no children in primary, try secondary") Reported-by: Maxim Levitsky <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/base/property.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 1e6d75e65938..d58aa98fe964 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -721,7 +721,7 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
return next;
/* When no more children in primary, continue with secondary */
- if (!IS_ERR_OR_NULL(fwnode->secondary))
+ if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
next = fwnode_get_next_child_node(fwnode->secondary, child);
return next;