[lvc-project] [PATCH] hwmon: tps23861: add regmap_bulk_read() handling in port resistance read

Pavel Zhigulin Pavel.Zhigulin at kaspersky.com
Fri Nov 14 18:00:44 MSK 2025


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 at kaspersky.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,
-			 &regval,
-			 2);
+	rc = regmap_bulk_read(data->regmap,
+			      PORT_1_RESISTANCE_LSB + PORT_N_RESISTANCE_LSB_OFFSET * port,
+			      &regval,
+			      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




More information about the lvc-project mailing list