Skip to content

Commit 47c29d6

Browse files
bluesheep1337sre
authored andcommitted
power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition
In bq24190_probe, &bdi->input_current_limit_work is bound with bq24190_input_current_limit_work. When external power changed, it will call bq24190_charger_external_power_changed to start the work. If we remove the module which will call bq24190_remove to make cleanup, there may be a unfinished work. The possible sequence is as follows: CPU0 CPUc1 |bq24190_input_current_limit_work bq24190_remove | power_supply_unregister | device_unregister | power_supply_dev_release| kfree(psy) | | | power_supply_get_property_from_supplier | //use Fix it by finishing the work before cleanup in the bq24190_remove Fixes: 9777467 ("power_supply: Initialize changed_work before calling device_add") Signed-off-by: Zheng Wang <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent bf6c880 commit 47c29d6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/power/supply/bq24190_charger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,7 @@ static void bq24190_remove(struct i2c_client *client)
19061906
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
19071907
int error;
19081908

1909+
cancel_delayed_work_sync(&bdi->input_current_limit_work);
19091910
error = pm_runtime_resume_and_get(bdi->dev);
19101911
if (error < 0)
19111912
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);

0 commit comments

Comments
 (0)