diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7a5d52948703..4a27a46ec6e7 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -380,16 +380,17 @@ static struct device_node *of_get_child_regulator(struct device_node *parent, if (!regnode) { regnode = of_get_child_regulator(child, prop_name); - if (regnode) { - of_node_put(child); - return regnode; - } + if (regnode) + goto err_node_put; } else { - of_node_put(child); - return regnode; + goto err_node_put; } } return NULL; + +err_node_put: + of_node_put(child); + return regnode; } /**