]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: max17040: Check iio_read_channel_processed() return code
authorIvan Abramov <i.abramov@mt-integration.ru>
Wed, 8 Oct 2025 13:36:47 +0000 (16:36 +0300)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 3 Nov 2025 00:01:57 +0000 (01:01 +0100)
Since iio_read_channel_processed() may fail, return its exit code on error.

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

Fixes: 814755c48f8b ("power: max17040: get thermal data from adc if available")
Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
Link: https://patch.msgid.link/20251008133648.559286-1-i.abramov@mt-integration.ru
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/max17040_battery.c

index c1640bc6accd27fd0338b9b34d5e81a163293a10..48453508688a49c80c1ef1773425a3acc7444568 100644 (file)
@@ -388,6 +388,7 @@ static int max17040_get_property(struct power_supply *psy,
                            union power_supply_propval *val)
 {
        struct max17040_chip *chip = power_supply_get_drvdata(psy);
+       int ret;
 
        switch (psp) {
        case POWER_SUPPLY_PROP_ONLINE:
@@ -410,7 +411,10 @@ static int max17040_get_property(struct power_supply *psy,
                if (!chip->channel_temp)
                        return -ENODATA;
 
-               iio_read_channel_processed(chip->channel_temp, &val->intval);
+               ret = iio_read_channel_processed(chip->channel_temp, &val->intval);
+               if (ret)
+                       return ret;
+
                val->intval /= 100; /* Convert from milli- to deci-degree */
 
                break;