Skip to content

Commit 2c68ac4

Browse files
Ivan Abramovsre
authored andcommitted
power: supply: max17040: Check iio_read_channel_processed() return code
Since iio_read_channel_processed() may fail, return its exit code on error. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 814755c ("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>
1 parent 92ec7e7 commit 2c68ac4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/power/supply/max17040_battery.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ static int max17040_get_property(struct power_supply *psy,
388388
union power_supply_propval *val)
389389
{
390390
struct max17040_chip *chip = power_supply_get_drvdata(psy);
391+
int ret;
391392

392393
switch (psp) {
393394
case POWER_SUPPLY_PROP_ONLINE:
@@ -410,7 +411,10 @@ static int max17040_get_property(struct power_supply *psy,
410411
if (!chip->channel_temp)
411412
return -ENODATA;
412413

413-
iio_read_channel_processed(chip->channel_temp, &val->intval);
414+
ret = iio_read_channel_processed(chip->channel_temp, &val->intval);
415+
if (ret)
416+
return ret;
417+
414418
val->intval /= 100; /* Convert from milli- to deci-degree */
415419

416420
break;

0 commit comments

Comments
 (0)