[PATCH 01/10] of: partition: check for valid node

Sascha Hauer s.hauer at pengutronix.de
Tue Jul 16 10:05:57 EDT 2013


So that users can call the of partition parsers without checking
if they are probed from the devicetree.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/of/partition.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index d69251e..7199eff 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -34,6 +34,9 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 	int len;
 	unsigned long flags = 0;
 
+	if (!node)
+		return NULL;
+
 	reg = of_get_property(node, "reg", &len);
 	if (!reg)
 		return NULL;
@@ -67,6 +70,9 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
 {
 	struct device_node *n;
 
+	if (!node)
+		return -EINVAL;
+
 	for_each_child_of_node(node, n) {
 		of_parse_partition(cdev, n);
 	}
-- 
1.8.3.2




More information about the barebox mailing list