Patch "power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()" has been added to the 6.0-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: cw2015: Fix potential null-ptr-deref in cw_bat_probe()

to the 6.0-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-cw2015-fix-potential-null-ptr-deref-in-.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 48df571f08b013391e9ed53cf55e6ae273f5e41f
Author: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
Date:   Thu Nov 17 10:45:58 2022 +0800

    power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()
    
    [ Upstream commit 97f2b4ddb0aa700d673691a7d5e44d226d22bab7 ]
    
    cw_bat_probe() calls create_singlethread_workqueue() and not checked the
    ret value, which may return NULL. And a null-ptr-deref may happen:
    
    cw_bat_probe()
        create_singlethread_workqueue() # failed, cw_bat->wq is NULL
        queue_delayed_work()
            queue_delayed_work_on()
                __queue_delayed_work()  # warning here, but continue
                    __queue_work()      # access wq->flags, null-ptr-deref
    
    Check the ret value and return -ENOMEM if it is NULL.
    
    Fixes: b4c7715c10c1 ("power: supply: add CellWise cw2015 fuel gauge driver")
    Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 6d52641151d9..473522b4326a 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -699,6 +699,9 @@ static int cw_bat_probe(struct i2c_client *client)
 	}
 
 	cw_bat->battery_workqueue = create_singlethread_workqueue("rk_battery");
+	if (!cw_bat->battery_workqueue)
+		return -ENOMEM;
+
 	devm_delayed_work_autocancel(&client->dev,
 							  &cw_bat->battery_delay_work, cw_bat_work);
 	queue_delayed_work(cw_bat->battery_workqueue,



[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