Commit 2f4e9420 authored by Zheng Wang's avatar Zheng Wang Committed by Treehugger Robot
Browse files

BACKPORT: power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition



[ Upstream commit 47c29d69 ]

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

Bug: 284459000
Fixes: 97774672 ("power_supply: Initialize changed_work before calling device_add")
Signed-off-by: default avatarZheng Wang <zyytlz.wz@163.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 4ca3fd39)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I79ae620284cfb87606d870cc7336b47006837db8
parent ce2c66d2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment