diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-03-12 03:44:12 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-03-13 18:15:52 -0400 |
commit | 1a352462b5377ac68f5955d674b3460c7bac52a3 (patch) | |
tree | b2dbecd8b038ccaddd262af47efa4fdf64c75696 /include | |
parent | 297d716f6260cc9421d971b124ca196b957ee458 (diff) |
power_supply: Add power_supply_put for decrementing device reference counter
The power_supply_get_by_phandle() and power_supply_get_by_name() use
function class_find_device() for obtaining the reference to power
supply. Each use of class_find_device() increases the power supply's
device reference counter.
However the reference counter was not decreased by users of this API.
Thus final device_unregister() call from power_supply_unregister() could
not release the device and clean up its resources. This lead to memory
leak if at least once power_supply_get_by_*() was called between
registering and unregistering the power supply.
Add and document new API power_supply_put() for decrementing the
reference counter.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/power_supply.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ea15eb68f609..75a1dd8dc56e 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h | |||
@@ -282,6 +282,7 @@ extern struct atomic_notifier_head power_supply_notifier; | |||
282 | extern int power_supply_reg_notifier(struct notifier_block *nb); | 282 | extern int power_supply_reg_notifier(struct notifier_block *nb); |
283 | extern void power_supply_unreg_notifier(struct notifier_block *nb); | 283 | extern void power_supply_unreg_notifier(struct notifier_block *nb); |
284 | extern struct power_supply *power_supply_get_by_name(const char *name); | 284 | extern struct power_supply *power_supply_get_by_name(const char *name); |
285 | extern void power_supply_put(struct power_supply *psy); | ||
285 | #ifdef CONFIG_OF | 286 | #ifdef CONFIG_OF |
286 | extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, | 287 | extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, |
287 | const char *property); | 288 | const char *property); |