From: Aleksandrova Alyona <aga@itb.spb.ru>
To: Mark Brown <broonie@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Laxman Dewangan <ldewangan@nvidia.com>,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH v3] regulator: palmas: Check return value of palmas_smps_write()
Date: Tue, 28 Jul 2026 15:30:31 +0300 [thread overview]
Message-ID: <20260728123031.8759-1-aga@itb.spb.ru> (raw)
palmas_set_mode_smps() updates the SMPS mode register when the rail is
enabled, but it ignores a possible error from palmas_smps_write().
If the register write fails, the function still reports success to the
caller even though the hardware mode has not been updated.
Return the error if palmas_smps_write() fails. Update current_reg_mode
and enable_val only after a successful register write so that the cached
driver state remains consistent with the hardware state.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 51d3a0c999e1 ("regulator: palmas: preserve modes of rails during enable/disable")
Signed-off-by: Aleksandrova Alyona <aga@itb.spb.ru>
---
v3:
- Remove the unnecessary new_mode variable.
v2:
- Update current_reg_mode and enable_val only after a successful register
write to keep the cached state consistent with the hardware state.
drivers/regulator/palmas-regulator.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 337dd614695e..d0e604780750 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -468,9 +468,14 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
return -EINVAL;
}
- pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
- if (rail_enable)
- palmas_smps_write(pmic->palmas, rinfo->ctrl_addr, reg);
+ if (rail_enable) {
+ ret = palmas_smps_write(pmic->palmas, rinfo->ctrl_addr, reg);
+ if (ret)
+ return ret;
+ }
+
+ pmic->current_reg_mode[id] =
+ reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
/* Switch the enable value to ensure this is used for enable */
pmic->desc[id].enable_val = pmic->current_reg_mode[id];
--
2.26.2
reply other threads:[~2026-07-28 12:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260728123031.8759-1-aga@itb.spb.ru \
--to=aga@itb.spb.ru \
--cc=broonie@kernel.org \
--cc=ldewangan@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=tony@atomide.com \
/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