Skip to content

Commit

Permalink
power: supply: core: Initialize struct to zero
Browse files Browse the repository at this point in the history
As we rely on pointers in the battery info to be zero-initialized
such as in the helper function power_supply_supports_vbat2ri()
we certainly need to allocate the struct power_supply_battery_info
with kzalloc() as well. Else this happens:

Unable to handle kernel paging request at virtual address 00280000
(...)
PC is at power_supply_vbat2ri+0x50/0x12c
LR is at ab8500_fg_battery_resistance+0x34/0x108

Fixes: e9e7d16 ("power: supply: Support VBAT-to-Ri lookup tables")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
  • Loading branch information
Linus Walleij authored and Sebastian Reichel committed May 3, 2022
1 parent 672c0c5 commit e56a4be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/power/supply/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
goto out_put_node;
}

info = devm_kmalloc(&psy->dev, sizeof(*info), GFP_KERNEL);
info = devm_kzalloc(&psy->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
err = -ENOMEM;
goto out_put_node;
Expand Down

0 comments on commit e56a4be

Please sign in to comment.