* [PATCH] power: supply: core: Initialize struct to zero
@ 2022-04-24 22:13 Linus Walleij
2022-05-03 15:36 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2022-04-24 22:13 UTC (permalink / raw)
To: Sebastian Reichel, Marcus Cooper; +Cc: linux-pm, Matti Vaittinen, Linus Walleij
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: e9e7d165b4b0 ("power: supply: Support VBAT-to-Ri lookup tables")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/power/supply/power_supply_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index d925cb137e12..fad5890c899e 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: core: Initialize struct to zero
2022-04-24 22:13 [PATCH] power: supply: core: Initialize struct to zero Linus Walleij
@ 2022-05-03 15:36 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2022-05-03 15:36 UTC (permalink / raw)
To: Linus Walleij; +Cc: Marcus Cooper, linux-pm, Matti Vaittinen
[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]
Hi,
On Mon, Apr 25, 2022 at 12:13:01AM +0200, Linus Walleij wrote:
> 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: e9e7d165b4b0 ("power: supply: Support VBAT-to-Ri lookup tables")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
Thanks, queued to fixes branch.
-- Sebastian
> drivers/power/supply/power_supply_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index d925cb137e12..fad5890c899e 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -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;
> --
> 2.35.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-03 15:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 22:13 [PATCH] power: supply: core: Initialize struct to zero Linus Walleij
2022-05-03 15:36 ` Sebastian Reichel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.