* [PATCH 5.10.y, 5.15.y] power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()
@ 2026-11-26 23:52 Nobuhiro Iwamatsu
2026-11-29 18:59 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Nobuhiro Iwamatsu @ 2026-11-26 23:52 UTC (permalink / raw)
To: stable; +Cc: gregkh, sashal, Shang XiaoJing, Sebastian Reichel,
Nobuhiro Iwamatsu
From: Shang XiaoJing <shangxiaojing@huawei.com>
commit 97f2b4ddb0aa700d673691a7d5e44d226d22bab7 u pstream.
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@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro.iwamatsu.x90@mail.toshiba>
---
drivers/power/supply/cw2015_battery.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index d1071dbb904e..616d481f834e 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -686,6 +686,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;
+
INIT_DELAYED_WORK(&cw_bat->battery_delay_work, cw_bat_work);
queue_delayed_work(cw_bat->battery_workqueue,
&cw_bat->battery_delay_work, msecs_to_jiffies(10));
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 23:52 [PATCH 5.10.y, 5.15.y] power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe() Nobuhiro Iwamatsu
2026-11-29 18:59 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox