power: supply: max77759: initialize registration, configurations
Subsystems (2)
PATCH 1/1 power: supply: max77759: initialize registration, configurations
Booting a Pixel 6 with CONFIG_INIT_STACK_NONE can oops in internal_create_group() while probing the MAX77759 charger. The probe only initializes fwnode and drv_data in its automatic power_supply_config. The power-supply core copies the uninitialized attr_grp into dev->groups, allowing sysfs to follow an invalid attribute-group pointer. The local regulator_config is also only partly initialized. Its unused init_data, regmap and ena_gpiod fields can be consumed by regulator core. Parsing the device tree does not initialize all of these fields.
Zero-initialize them both configurations before used fields are assigned.
--- drivers/power/supply/max77759_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/max77759_charger.c +2 -2
@@ -683,8 +683,8 @@ static void max_tcpci_unregister_psy_notifier(void *nb)static int max77759_charger_probe (struct platform_device *pdev) { -struct regulator_config chgin_otg_reg_cfg; -struct power_supply_config psy_cfg; +struct regulator_config chgin_otg_reg_cfg = {}; +struct power_supply_config psy_cfg = {};struct device *dev = &pdev->dev;struct max77759_charger *chg;int ret;
Signature · 1 line
2.34.1
Quoted 9 lines · Christian Loehle
Booting a Pixel 6 with
CONFIG_INIT_STACK_NONEcan oops ininternal_create_group()while probing the MAX77759 charger. The probe only initializes fwnode anddrv_datain its automaticpower_supply_config. The power-supply core copies the uninitializedattr_grpintodev->groups, allowing sysfs to follow an invalid attribute-group pointer. The localregulator_configis also only partly initialized. Its unusedinit_data, regmap andena_gpiodfields can be consumed by regulator core. Parsing the device tree does not initialize all of these fields.
Quoted 6 lines
Zero-initialize them both configurations before used fields are assigned.
Fixes 70d7dd27f6dc ("power: supply: max77759: add charger driver")Signed-off-by Christian Loehle <[email protected]>
Quoted 19 lines
--- drivers/power/supply/max77759_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/supply/max77759_charger.c +2
-2@@ -683,8 +683,8 @@ static void max_tcpci_unregister_psy_notifier(void *nb)static int max77759_charger_probe (struct platform_device *pdev) { -struct regulator_config chgin_otg_reg_cfg; -struct power_supply_config psy_cfg; +struct regulator_config chgin_otg_reg_cfg = {}; +struct power_supply_config psy_cfg = {};struct device *dev = &pdev->dev;struct max77759_charger *chg;int ret;
Sebastian Reichel
AppliedQuoted 10 lines · Christian Loehle
Booting a Pixel 6 with
CONFIG_INIT_STACK_NONEcan oops ininternal_create_group()while probing the MAX77759 charger. The probe only initializes fwnode anddrv_datain its automaticpower_supply_config. The power-supply core copies the uninitializedattr_grpintodev->groups, allowing sysfs to follow an invalid attribute-group pointer. The localregulator_configis also only partly initialized. Its unusedinit_data, regmap andena_gpiodfields can be consumed by regulator core. Parsing the device tree does not initialize all of these fields.[...]
Applied, thanks!
[1/1] power: supply: max77759: initialize registration, configurations
commit: f49a9afecd6d55842dab3f9b0ccb702d49db6654
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>