OSDN Git Service

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)
commitcdf10ffe8f626d8a2edc354abf063df0078b2d71
tree235c1a94f992b9de6b8b2c815e0c48ab4c056cb3
parent172d0ccea55ce69718bac693d2ea9341fb61b6c7
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: 703df6c09795 ("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