drivers/regulator: fix a missing check of return value
Subsystems (2)
PATCH 1/1 drivers/regulator: fix a missing check of return value
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".
--- drivers/regulator/palmas-regulator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/palmas-regulator.c +4 -1
@@ -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) {int id =rdev_get_id (dev); +int ret;struct palmas_pmic *pmic =rdev_get_drvdata (dev);struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];unsigned int reg;bool rail_enable = true; -palmas_smps_read (pmic->palmas, rinfo->ctrl_addr, ®); + ret =palmas_smps_read (pmic->palmas, rinfo->ctrl_addr, ®); +if (ret) +return ret; reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK ;
Signature · 1 line
2.17.2 (Apple Git-113)
Mark Brown
maintainerQuoted 4 lines · Kangjie Lu
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 ofpalmas_smps_read(): If it fails, we return the error code upstream and stop using "reg".
Please use subject lines matching the style for the subsystem. This makes it easier for people to identify relevant patches.
PATCH v2 1/1 regulator: palmas: fix a missing check of return value
In reply to Kangjie LuIf 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".
--- drivers/regulator/palmas-regulator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/palmas-regulator.c +4 -1
@@ -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) {int id =rdev_get_id (dev); +int ret;struct palmas_pmic *pmic =rdev_get_drvdata (dev);struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];unsigned int reg;bool rail_enable = true; -palmas_smps_read (pmic->palmas, rinfo->ctrl_addr, ®); + ret =palmas_smps_read (pmic->palmas, rinfo->ctrl_addr, ®); +if (ret) +return ret; reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK ;
Signature · 1 line
2.17.2 (Apple Git-113)
Mark Brown
maintainerRe: [PATCH v2] regulator: palmas: fix a missing check of return value
Quoted 4 lines · Kangjie Lu
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 ofpalmas_smps_read(): If it fails, we return the error code upstream and stop using "reg".
Ah, thanks - I'd actually already applied the earlier version!