]> Git Repo - linux.git/commitdiff
device property: Avoid NULL pointer dereference in device_get_next_child_node()
authorAndy Shevchenko <[email protected]>
Thu, 16 Jul 2020 18:27:47 +0000 (21:27 +0300)
committerGreg Kroah-Hartman <[email protected]>
Thu, 23 Jul 2020 15:04:28 +0000 (17:04 +0200)
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]>
drivers/base/property.c

index 1e6d75e65938fb8247c66adb3baa6181f8058920..d58aa98fe9645703b5be22c16d89241f663600a5 100644 (file)
@@ -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;
This page took 0.054741 seconds and 4 git commands to generate.