mfd: mc13xxx: fix a missing check of a register-read failure
PATCH 1/1 mfd: mc13xxx: fix a missing check of a register-read failure
When mc13xxx_reg_read() fails, "old_adc0" is uninitialized and will contain random value. Further execution uses "old_adc0" even when mc13xxx_reg_read() fails.
The fix checks the return value of mc13xxx_reg_read(), and exits the execution when it fails.
Signed-off-by Kangjie Lu <[email protected]>
--- drivers/mfd/mc13xxx-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mfd/mc13xxx-core.c +3 -1
@@ -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.1
Lee Jones
AppliedQuoted 10 lines · Kangjie Lu
When
mc13xxx_reg_read()fails, "old_adc0" is uninitialized and will contain random value. Further execution uses "old_adc0" even whenmc13xxx_reg_read()fails.
The fix checks the return value ofmc13xxx_reg_read(), and exits the execution when it fails.Signed-off-by Kangjie Lu <[email protected]>--- drivers/mfd/mc13xxx-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog