mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 00:04:15 +08:00
thermal: qcom: Fix comparison with uninitialized variable channels_available
Currently the check of chip->channels[i].channel is against an the
uninitialized variable channels_available. I believe the variable
channels_available needs to be fetched first by the call to adc_tm5_read
before the channels check. Fix the issue swapping the order of the
channels check loop with the call to adc_tm5_read.
Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: ca66dca5ed
("thermal: qcom: add support for adc-tm5 PMIC thermal monitor")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210216151626.162996-1-colin.king@canonical.com
This commit is contained in:
parent
ca66dca5ed
commit
74369d041a
@ -375,13 +375,6 @@ static int adc_tm5_init(struct adc_tm5_chip *chip)
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < chip->nchannels; i++) {
|
||||
if (chip->channels[i].channel >= channels_available) {
|
||||
dev_err(chip->dev, "Invalid channel %d\n", chip->channels[i].channel);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
ret = adc_tm5_read(chip, ADC_TM5_NUM_BTM,
|
||||
&channels_available, sizeof(channels_available));
|
||||
if (ret) {
|
||||
@ -389,6 +382,13 @@ static int adc_tm5_init(struct adc_tm5_chip *chip)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < chip->nchannels; i++) {
|
||||
if (chip->channels[i].channel >= channels_available) {
|
||||
dev_err(chip->dev, "Invalid channel %d\n", chip->channels[i].channel);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
buf[0] = chip->decimation;
|
||||
buf[1] = chip->avg_samples | ADC_TM5_FAST_AVG_EN;
|
||||
buf[2] = ADC_TM5_TIMER1;
|
||||
|
Loading…
Reference in New Issue
Block a user