Commit 2054d6e9 authored by Rhyland Klein's avatar Rhyland Klein Committed by Anton Vorontsov

power_supply: Add of_node_put to fix refcount

of_parse_phandle increments the refcount for a dt node before returning
it. Add of_node_put where needed to properly decrement the refcount when
we are done using a given node.
Signed-off-by: default avatarRhyland Klein <rklein@nvidia.com>
Signed-off-by: default avatarAnton Vorontsov <anton@enomsg.org>
parent b50df95c
...@@ -109,8 +109,10 @@ static int __power_supply_populate_supplied_from(struct device *dev, ...@@ -109,8 +109,10 @@ static int __power_supply_populate_supplied_from(struct device *dev,
psy->name, epsy->name); psy->name, epsy->name);
psy->supplied_from[i-1] = (char *)epsy->name; psy->supplied_from[i-1] = (char *)epsy->name;
psy->num_supplies++; psy->num_supplies++;
of_node_put(np);
break; break;
} }
of_node_put(np);
} while (np); } while (np);
return 0; return 0;
...@@ -193,8 +195,10 @@ static int power_supply_check_supplies(struct power_supply *psy) ...@@ -193,8 +195,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
ret = power_supply_find_supply_from_node(np); ret = power_supply_find_supply_from_node(np);
if (ret) { if (ret) {
dev_dbg(psy->dev, "Failed to find supply, defer!\n"); dev_dbg(psy->dev, "Failed to find supply, defer!\n");
of_node_put(np);
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
of_node_put(np);
} while (np); } while (np);
/* All supplies found, allocate char ** array for filling */ /* All supplies found, allocate char ** array for filling */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment