summaryrefslogtreecommitdiff
path: root/include/linux/power_supply.h
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2015-03-12 10:44:12 +0300
committerSebastian Reichel <sre@kernel.org>2015-03-14 01:15:52 +0300
commit1a352462b5377ac68f5955d674b3460c7bac52a3 (patch)
treeb2dbecd8b038ccaddd262af47efa4fdf64c75696 /include/linux/power_supply.h
parent297d716f6260cc9421d971b124ca196b957ee458 (diff)
downloadlinux-1a352462b5377ac68f5955d674b3460c7bac52a3.tar.xz
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/linux/power_supply.h')
-rw-r--r--include/linux/power_supply.h1
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;
extern int power_supply_reg_notifier(struct notifier_block *nb);
extern void power_supply_unreg_notifier(struct notifier_block *nb);
extern struct power_supply *power_supply_get_by_name(const char *name);
+extern void power_supply_put(struct power_supply *psy);
#ifdef CONFIG_OF
extern struct power_supply *power_supply_get_by_phandle(struct device_node *np,
const char *property);