Skip to content

Commit

Permalink
power: supply: axp20x_usb_power: Init work before enabling IRQs
Browse files Browse the repository at this point in the history
[ Upstream commit b5e8642 ]

The IRQ handler calls mod_delayed_work() on power->vbus_detect. However,
that work item is not initialized until after the IRQs are enabled. If
an IRQ is already pending when the driver is probed, the driver calls
mod_delayed_work() on an uninitialized work item, which causes an oops.

Fixes: bcfb7ae ("power: supply: axp20x_usb_power: Only poll while offline")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
smaeul authored and gregkh committed Mar 4, 2021
1 parent b1ff96e commit 564c05d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/power/supply/axp20x_usb_power.c
Expand Up @@ -593,6 +593,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
power->axp20x_id = axp_data->axp20x_id;
power->regmap = axp20x->regmap;
power->num_irqs = axp_data->num_irq_names;
INIT_DELAYED_WORK(&power->vbus_detect, axp20x_usb_power_poll_vbus);

if (power->axp20x_id == AXP202_ID) {
/* Enable vbus valid checking */
Expand Down Expand Up @@ -645,7 +646,6 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
}
}

INIT_DELAYED_WORK(&power->vbus_detect, axp20x_usb_power_poll_vbus);
if (axp20x_usb_vbus_needs_polling(power))
queue_delayed_work(system_wq, &power->vbus_detect, 0);

Expand Down

0 comments on commit 564c05d

Please sign in to comment.