Commit 6e5176f5 authored by Kangjie Lu's avatar Kangjie Lu Committed by Greg Kroah-Hartman

drivers/regulator: fix a missing check of return value

[ Upstream commit 966e927b ]

If palmas_smps_read() fails, we should not use the read data in "reg"
which may contain random value. The fix inserts a check for the return
value of palmas_smps_read(): If it fails, we return the error code
upstream and stop using "reg".
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent b5a1a46d
...@@ -443,13 +443,16 @@ static int palmas_ldo_write(struct palmas *palmas, unsigned int reg, ...@@ -443,13 +443,16 @@ static int palmas_ldo_write(struct palmas *palmas, unsigned int reg,
static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
{ {
int id = rdev_get_id(dev); int id = rdev_get_id(dev);
int ret;
struct palmas_pmic *pmic = rdev_get_drvdata(dev); struct palmas_pmic *pmic = rdev_get_drvdata(dev);
struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata; struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;
struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id]; struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
unsigned int reg; unsigned int reg;
bool rail_enable = true; bool rail_enable = true;
palmas_smps_read(pmic->palmas, rinfo->ctrl_addr, &reg); ret = palmas_smps_read(pmic->palmas, rinfo->ctrl_addr, &reg);
if (ret)
return ret;
reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment