[PATCH 02/22] OF: base: bail out early on missing matches for of_match_node

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Tue Jun 18 13:29:47 EDT 2013


of_match_node checks for compatiblity between a set of matches and a
node. Neither the matches nor node pointer are checked for validity.
This adds the required checks to of_match_node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Cc: barebox at lists.infradead.org
---
 drivers/of/base.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4241e65..ab0f4cd 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -321,6 +321,9 @@ EXPORT_SYMBOL(of_device_is_compatible);
 const struct of_device_id *of_match_node(const struct of_device_id *matches,
 					 const struct device_node *node)
 {
+	if (!matches || !node)
+		return NULL;
+
 	while (matches->compatible) {
 		if (of_device_is_compatible(node, matches->compatible) == 1)
 			return matches;
-- 
1.7.2.5




More information about the barebox mailing list