]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: bq27xxx: Fix kernel crash on IRQ handler register error
authorHans de Goede <hdegoede@redhat.com>
Sun, 31 Oct 2021 15:25:22 +0000 (16:25 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 2 Nov 2021 12:47:19 +0000 (13:47 +0100)
commit70b5ca6d77bf262d4ef1b6bbf5a0f42a05badf1c
tree235c1a94f992b9de6b8b2c815e0c48ab4c056cb3
parent070dae1cef7a5b172b309184ae8c07cf910a2ae5
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: 752f3f1ed60a ("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>
drivers/power/supply/bq27xxx_battery_i2c.c