Skip to content

Commit cdf10ff

Browse files
jwrdegoedesre
authored andcommitted
power: supply: bq27xxx: Fix kernel crash on IRQ handler register error
When registering the IRQ handler fails, do not just return the error code, this will free the devm_kzalloc()-ed data struct while leaving the queued work queued and the registered power_supply registered with both of them now pointing to free-ed memory, resulting in various kernel crashes soon afterwards. Instead properly tear-down things on IRQ handler register errors. Fixes: 703df6c ("power: bq27xxx_battery: Reorganize I2C into a module") Cc: Andrew F. Davis <afd@ti.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 172d0cc commit cdf10ff

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/power/supply/bq27xxx_battery_i2c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
187187
dev_err(&client->dev,
188188
"Unable to register IRQ %d error %d\n",
189189
client->irq, ret);
190-
return ret;
190+
bq27xxx_battery_teardown(di);
191+
goto err_failed;
191192
}
192193
}
193194

0 commit comments

Comments
 (0)