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 5/5] hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit()
Date: Tue, 17 Mar 2026 17:46:54 +0000 [thread overview]
Message-ID: <20260317174553.385567-2-sanman.pradhan@hpe.com> (raw)
In-Reply-To: <20260317174553.385567-1-sanman.pradhan@hpe.com>
From: Sanman Pradhan <psanman@juniper.net>
isl68137_avs_enable_show_page() uses the return value of
pmbus_read_byte_data() without checking for errors. If the I2C transaction
fails, the negative error code is passed through the bitmask test and
sprintf, producing incorrect output instead of propagating the error.
Additionally, replace sprintf() with sysfs_emit() which is the preferred
API for sysfs show callbacks since v5.10.
Fixes: 038a9c3d1e424 ("hwmon: (pmbus/isl68137) Add driver for Intersil ISL68137 PWM Controller")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
drivers/hwmon/pmbus/isl68137.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
index 97b61836f53a4..739e7126be51c 100644
--- a/drivers/hwmon/pmbus/isl68137.c
+++ b/drivers/hwmon/pmbus/isl68137.c
@@ -98,8 +98,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
{
int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
- return sprintf(buf, "%d\n",
- (val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
+ if (val < 0)
+ return val;
+
+ return sysfs_emit(buf, "%d\n",
+ !!(val & ISL68137_VOUT_AVS));
}
static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,
--
2.34.1
next prev parent reply other threads:[~2026-03-17 17:47 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 ` [PATCH 1/5] hwmon: (pmbus/hac300s) Add error check for pmbus_read_word_data() return value Pradhan, Sanman
2026-03-17 22:20 ` 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 ` Pradhan, Sanman [this message]
2026-03-17 22:21 ` 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=20260317174553.385567-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®