Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52355fd4 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman
Browse files

power: supply: bq27xxx: Fix kernel crash on IRQ handler register error



[ Upstream commit cdf10ffe8f626d8a2edc354abf063df0078b2d71 ]

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: 703df6c0 ("power: bq27xxx_battery: Reorganize I2C into a module")
Cc: Andrew F. Davis <afd@ti.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 00b6103b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
			dev_err(&client->dev,
				"Unable to register IRQ %d error %d\n",
				client->irq, ret);
			return ret;
			bq27xxx_battery_teardown(di);
			goto err_failed;
		}
	}