提交 1d7a7128 编写于 作者: Q Qiushi Wu 提交者: Sebastian Reichel

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: e67d4dfc ("power: supply: Add HWMON compatibility layer")
Signed-off-by: NQiushi Wu <wu000273@umn.edu>
Signed-off-by: NSebastian Reichel <sebastian.reichel@collabora.com>
上级 21d4cdf8
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册