[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251114150045.2230687-1-Pavel.Zhigulin@kaspersky.com>
Date: Fri, 14 Nov 2025 18:00:44 +0300
From: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
To: Robert Marko <robert.marko@...tura.hr>
CC: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>, Luka Perkov
<luka.perkov@...tura.hr>, Guenter Roeck <linux@...ck-us.net>,
<linux-hwmon@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH] hwmon: tps23861: add regmap_bulk_read() handling in port resistance read
regmap_bulk_read() was called without checking its return value
in function tps23861_port_resistance(). If the read failed,
the code proceeded with an uninitialized register value.
Add return value handling
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
---
drivers/hwmon/tps23861.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
index 4cb3960d5170..8873b2e21064 100644
--- a/drivers/hwmon/tps23861.c
+++ b/drivers/hwmon/tps23861.c
@@ -457,13 +457,16 @@ static char *port_poe_plus_status_string(uint8_t poe_plus, unsigned int port)
static int tps23861_port_resistance(struct tps23861_data *data, int port)
{
unsigned int raw_val;
+ int rc = 0;
__le16 regval;
- regmap_bulk_read(data->regmap,
- PORT_1_RESISTANCE_LSB + PORT_N_RESISTANCE_LSB_OFFSET * port,
- ®val,
- 2);
+ rc = regmap_bulk_read(data->regmap,
+ PORT_1_RESISTANCE_LSB + PORT_N_RESISTANCE_LSB_OFFSET * port,
+ ®val,
+ 2);
+ if (rc < 0)
+ return 0;
raw_val = le16_to_cpu(regval);
switch (FIELD_GET(PORT_RESISTANCE_RSN_MASK, raw_val)) {
case PORT_RESISTANCE_RSN_OTHER:
--
2.43.0
Powered by blists - more mailing lists