mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 21:23:23 +00:00
power: supply: core: fix memory leak in HWMON error path
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>
This commit is contained in:
parent
21d4cdf8b3
commit
1d7a7128a2
@ -358,7 +358,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user