Skip to content

Commit

Permalink
power_supply: Add of_node_put to fix refcount
Browse files Browse the repository at this point in the history
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: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
  • Loading branch information
Rhyland Klein authored and Anton Vorontsov committed Jun 29, 2013
1 parent b50df95 commit 2054d6e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/power/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ static int __power_supply_populate_supplied_from(struct device *dev,
psy->name, epsy->name);
psy->supplied_from[i-1] = (char *)epsy->name;
psy->num_supplies++;
of_node_put(np);
break;
}
of_node_put(np);
} while (np);

return 0;
Expand Down Expand Up @@ -193,8 +195,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
ret = power_supply_find_supply_from_node(np);
if (ret) {
dev_dbg(psy->dev, "Failed to find supply, defer!\n");
of_node_put(np);
return -EPROBE_DEFER;
}
of_node_put(np);
} while (np);

/* All supplies found, allocate char ** array for filling */
Expand Down

0 comments on commit 2054d6e

Please sign in to comment.