Skip to contentSkip to conversation

power: supply: max77759: initialize registration, configurations

PATCH Applied Christian Loehle 3 participants 3 messages Nov 9 – Nov 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 70d7dd27f6dc ("power: supply: max77759: add charger driver")
---
 drivers/power/supply/max77759_charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/max77759_charger.c +2 -2
index a93adb266f01..e792327ff14f 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christian Loehle

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.

Quoted 6 lines

Zero-initialize them both configurations before used fields are assigned.

Fixes 70d7dd27f6dc ("power: supply: max77759: add charger driver")
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
index a93adb266f01..e792327ff14f 100644
@@ -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;
#2 lore raw
In reply to Christian Loehle
Quoted 10 lines · Christian Loehle

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.

[...]

Applied, thanks!

[1/1] power: supply: max77759: initialize registration, configurations

      commit: f49a9afecd6d55842dab3f9b0ccb702d49db6654

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>