]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dt: protect against NULL matches passed to of_match_node()
authorGrant Likely <grant.likely@secretlab.ca>
Fri, 18 Mar 2011 16:21:29 +0000 (10:21 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Wed, 23 Mar 2011 20:55:55 +0000 (14:55 -0600)
There are a few use cases where it is convenient to pass NULL to
of_match_node() and have it fail gracefully.  The patch adds a null
check to the beginning so taht it does so.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/of/base.c

index 710b53bfac6d9478b86aed67e537bc06ee1cbc6d..632ebae7f17a4444f7aa3ad193bdbce0212c6c09 100644 (file)
@@ -496,6 +496,9 @@ EXPORT_SYMBOL(of_find_node_with_property);
 const struct of_device_id *of_match_node(const struct of_device_id *matches,
                                         const struct device_node *node)
 {
+       if (!matches)
+               return NULL;
+
        while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
                int match = 1;
                if (matches->name[0])