]> Gentwo Git Trees - linux/.git/commitdiff
power: supply: cw2015: Check devm_delayed_work_autocancel() return code
authorIvan Abramov <i.abramov@mt-integration.ru>
Wed, 8 Oct 2025 12:07:11 +0000 (15:07 +0300)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 3 Nov 2025 00:01:57 +0000 (01:01 +0100)
Since devm_delayed_work_autocancel() may fail, add return code check and
exit cw_bat_probe() on error.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 0cb172a4918e ("power: supply: cw2015: Use device managed API to simplify the code")
Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
Link: https://patch.msgid.link/20251008120711.556021-1-i.abramov@mt-integration.ru
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/cw2015_battery.c

index 2263d5d3448fdfbd634b337dca7204cb248c7fe5..0806abea2372fec739ceebca61a869d0af6daeca 100644 (file)
@@ -699,7 +699,13 @@ static int cw_bat_probe(struct i2c_client *client)
        if (!cw_bat->battery_workqueue)
                return -ENOMEM;
 
-       devm_delayed_work_autocancel(&client->dev, &cw_bat->battery_delay_work, cw_bat_work);
+       ret = devm_delayed_work_autocancel(&client->dev, &cw_bat->battery_delay_work, cw_bat_work);
+       if (ret) {
+               dev_err_probe(&client->dev, ret,
+                       "Failed to register delayed work\n");
+               return ret;
+       }
+
        queue_delayed_work(cw_bat->battery_workqueue,
                           &cw_bat->battery_delay_work, msecs_to_jiffies(10));
        return 0;