summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorQiushi Wu <wu000273@umn.edu>2020-05-02 18:33:38 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-22 09:31:20 +0200
commit8b28e5c35d3272e367953fba52cd72fd86573488 (patch)
tree930d47a2826ace68af8467fab433d20afc0d4a18 /drivers/power
parent6050811edffbe9ce1b264e1557875f81b64f40e4 (diff)
power: supply: core: fix memory leak in HWMON error path
commit 1d7a7128a2e9e1f137c99b0a44e94d70a77343e3 upstream. In function power_supply_add_hwmon_sysfs(), psyhw->props is allocated by bitmap_zalloc(). But this pointer is not deallocated when devm_add_action fail, which lead to a memory leak bug. To fix this, we replace devm_add_action with devm_add_action_or_reset. Cc: stable@kernel.org Fixes: e67d4dfc9ff19 ("power: supply: Add HWMON compatibility layer") Signed-off-by: Qiushi Wu <wu000273@umn.edu> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/power_supply_hwmon.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
index 67b6ee60085e..2e7e2b73b012 100644
--- a/drivers/power/supply/power_supply_hwmon.c
+++ b/drivers/power/supply/power_supply_hwmon.c
@@ -304,7 +304,7 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
goto error;
}
- ret = devm_add_action(dev, power_supply_hwmon_bitmap_free,
+ ret = devm_add_action_or_reset(dev, power_supply_hwmon_bitmap_free,
psyhw->props);
if (ret)
goto error;