Skip to content

Commit

Permalink
mfd: mc13xxx: Fix a missing check of a register-read failure
Browse files Browse the repository at this point in the history
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 <kjlu@umn.edu>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Kangjie Lu authored and Lee Jones committed Jan 3, 2019
1 parent c1f3375 commit 9e28989
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/mfd/mc13xxx-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9e28989

Please sign in to comment.