Patch "power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     power-supply-bq24190-fix-use-after-free-bug-in-bq241.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d4f4f7347e38ef52d49b79bedc39080decf28a78
Author: Zheng Wang <zyytlz.wz@xxxxxxx>
Date:   Fri Mar 10 01:47:28 2023 +0800

    power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition
    
    [ Upstream commit 47c29d69212911f50bdcdd0564b5999a559010d4 ]
    
    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: 97774672573a ("power_supply: Initialize changed_work before calling device_add")
    Signed-off-by: Zheng Wang <zyytlz.wz@xxxxxxx>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 81389fcc73e14..338dd82007e4e 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -1834,6 +1834,7 @@ static int bq24190_remove(struct i2c_client *client)
 	struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
 	int error;
 
+	cancel_delayed_work_sync(&bdi->input_current_limit_work);
 	error = pm_runtime_resume_and_get(bdi->dev);
 	if (error < 0)
 		dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux