Skip to content

Commit 97f2b4d

Browse files
Shang XiaoJingsre
authored andcommitted
power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()
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: b4c7715 ("power: supply: add CellWise cw2015 fuel gauge driver") Signed-off-by: Shang XiaoJing <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 955bee2 commit 97f2b4d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/power/supply/cw2015_battery.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ static int cw_bat_probe(struct i2c_client *client)
699699
}
700700

701701
cw_bat->battery_workqueue = create_singlethread_workqueue("rk_battery");
702+
if (!cw_bat->battery_workqueue)
703+
return -ENOMEM;
704+
702705
devm_delayed_work_autocancel(&client->dev,
703706
&cw_bat->battery_delay_work, cw_bat_work);
704707
queue_delayed_work(cw_bat->battery_workqueue,

0 commit comments

Comments
 (0)