* [PATCH][next] thermal: qcom: Fix comparison with uninitialized variable channels_available
@ 2021-02-16 15:16 Colin King
2021-02-18 20:39 ` [thermal: thermal/next] " thermal-bot for Colin Ian King
2021-03-01 19:59 ` [PATCH][next] " patchwork-bot+linux-arm-msm
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-02-16 15:16 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Amit Kucheria, Zhang Rui,
Daniel Lezcano, Dmitry Baryshkov, linux-arm-msm, linux-pm
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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: ca66dca5eda6 ("thermal: qcom: add support for adc-tm5 PMIC thermal monitor")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index a2014375587d..b460b56e981c 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -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;
--
2.30.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [thermal: thermal/next] thermal: qcom: Fix comparison with uninitialized variable channels_available
2021-02-16 15:16 [PATCH][next] thermal: qcom: Fix comparison with uninitialized variable channels_available Colin King
@ 2021-02-18 20:39 ` thermal-bot for Colin Ian King
2021-03-01 19:59 ` [PATCH][next] " patchwork-bot+linux-arm-msm
1 sibling, 0 replies; 3+ messages in thread
From: thermal-bot for Colin Ian King @ 2021-02-18 20:39 UTC (permalink / raw)
To: linux-pm; +Cc: Colin Ian King, Daniel Lezcano, rui.zhang, amitk
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 74369d041a0a3e9e57de50efd4bd4bc10564e254
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//74369d041a0a3e9e57de50efd4bd4bc10564e254
Author: Colin Ian King <colin.king@canonical.com>
AuthorDate: Tue, 16 Feb 2021 15:16:26
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Tue, 16 Feb 2021 19:05:23 +01: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: ca66dca5eda6 ("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
---
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index a201437..b460b56 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] thermal: qcom: Fix comparison with uninitialized variable channels_available
2021-02-16 15:16 [PATCH][next] thermal: qcom: Fix comparison with uninitialized variable channels_available Colin King
2021-02-18 20:39 ` [thermal: thermal/next] " thermal-bot for Colin Ian King
@ 2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-03-01 19:59 UTC (permalink / raw)
To: Colin King; +Cc: linux-arm-msm
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
On Tue, 16 Feb 2021 15:16:26 +0000 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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.
>
> [...]
Here is the summary with links:
- [next] thermal: qcom: Fix comparison with uninitialized variable channels_available
https://git.kernel.org/qcom/c/74369d041a0a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-01 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 15:16 [PATCH][next] thermal: qcom: Fix comparison with uninitialized variable channels_available Colin King
2021-02-18 20:39 ` [thermal: thermal/next] " thermal-bot for Colin Ian King
2021-03-01 19:59 ` [PATCH][next] " patchwork-bot+linux-arm-msm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.