Skip to contentSkip to conversation

mfd: add a check for the status of mc13xxx_reg_read

PATCH New Kangjie Lu 1 participant 1 message Dec 25, 2018 Multifunction devices (MFD)

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 mfd: add a check for the status of mc13xxx_reg_read

When mc13xxx_reg_read() fails, old_adc0 could be a random value and should not be used. The fix checks the status of mc13xxx_reg_read(): if it fails, returns with its error code.

---
 drivers/mfd/mc13xxx-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mfd/mc13xxx-core.c +3 -1
index f475e848252f..d0bf50e3568d 100644
@@ -274,7 +274,9 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 
 	mc13xxx->adcflags |= MC13XXX_ADC_WORKING;
 
-	mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
+	ret = mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
+	if (ret)
+		goto out;
 
 	adc0 = MC13XXX_ADC0_ADINC1 | MC13XXX_ADC0_ADINC2 |
 	       MC13XXX_ADC0_CHRGRAWDIV;
Signature · 1 line
2.17.2 (Apple Git-113)