{
struct software_node *swnode = to_software_node(fwnode);
- return swnode->parent ? &swnode->parent->fwnode : NULL;
+ return swnode ? (swnode->parent ? &swnode->parent->fwnode : NULL) :
+ NULL;
}
struct fwnode_handle *
struct software_node *p = to_software_node(fwnode);
struct software_node *c = to_software_node(child);
- if (list_empty(&p->children) ||
+ if (!p || list_empty(&p->children) ||
(c && list_is_last(&c->entry, &p->children)))
return NULL;