From: "Pradhan, Sanman" <sanman.pradhan@hpe.com>
To: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Cc: "linux@roeck-us.net" <linux@roeck-us.net>,
"vasileios.amoiridis@cern.ch" <vasileios.amoiridis@cern.ch>,
"leo.yang.sy0@gmail.com" <leo.yang.sy0@gmail.com>,
"wensheng@yeah.net" <wensheng@yeah.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Sanman Pradhan <psanman@juniper.net>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH 1/5] hwmon: (pmbus/hac300s) Add error check for pmbus_read_word_data() return value
Date: Tue, 17 Mar 2026 17:36:53 +0000 [thread overview]
Message-ID: <20260317173308.382545-2-sanman.pradhan@hpe.com> (raw)
In-Reply-To: <20260317173308.382545-1-sanman.pradhan@hpe.com>
From: Sanman Pradhan <psanman@juniper.net>
hac300s_read_word_data() passes the return value of pmbus_read_word_data()
directly to FIELD_GET() without checking for errors. If the I2C transaction
fails, a negative error code is sign-extended and passed to FIELD_GET(),
which silently produces garbage data instead of propagating the error.
Add the missing error check before using the return value in
the FIELD_GET() macro.
Fixes: 669cf162f7a1 ("hwmon: Add support for HiTRON HAC300S PSU")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
drivers/hwmon/pmbus/hac300s.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/pmbus/hac300s.c b/drivers/hwmon/pmbus/hac300s.c
index 0a1d52cae91ed..a073db1cfe2e4 100644
--- a/drivers/hwmon/pmbus/hac300s.c
+++ b/drivers/hwmon/pmbus/hac300s.c
@@ -58,6 +58,8 @@ static int hac300s_read_word_data(struct i2c_client *client, int page,
case PMBUS_MFR_VOUT_MIN:
case PMBUS_READ_VOUT:
rv = pmbus_read_word_data(client, page, phase, reg);
+ if (rv < 0)
+ return rv;
return FIELD_GET(LINEAR11_MANTISSA_MASK, rv);
default:
return -ENODATA;
--
2.34.1
next prev parent reply other threads:[~2026-03-17 17:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 17:36 [PATCH 0/5] hwmon: (pmbus) Fix unchecked error returns in multiple drivers Pradhan, Sanman
2026-03-17 17:36 ` Pradhan, Sanman [this message]
2026-03-17 22:20 ` [PATCH 1/5] hwmon: (pmbus/hac300s) Add error check for pmbus_read_word_data() return value Guenter Roeck
2026-03-17 17:37 ` [PATCH 2/5] hwmon: (pmbus/mp2975) " Pradhan, Sanman
2026-03-17 22:20 ` Guenter Roeck
2026-03-17 17:37 ` [PATCH 3/5] hwmon: (pmbus/mp2869) Check pmbus_read_byte_data() before using its " Pradhan, Sanman
2026-03-17 22:21 ` Guenter Roeck
2026-03-17 17:46 ` [PATCH 4/5] hwmon: (pmbus/ina233) Add error check for pmbus_read_word_data() " Pradhan, Sanman
2026-03-17 17:46 ` [PATCH 5/5] hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit() Pradhan, Sanman
2026-03-17 22:21 ` [PATCH 4/5] hwmon: (pmbus/ina233) Add error check for pmbus_read_word_data() return value Guenter Roeck
2026-03-17 22:23 ` [PATCH 0/5] hwmon: (pmbus) Fix unchecked error returns in multiple drivers Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260317173308.382545-2-sanman.pradhan@hpe.com \
--to=sanman.pradhan@hpe.com \
--cc=leo.yang.sy0@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=psanman@juniper.net \
--cc=stable@vger.kernel.org \
--cc=vasileios.amoiridis@cern.ch \
--cc=wensheng@yeah.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®