* [PATCH v2] asus-laptop: Fix an uninitialized variable
@ 2025-04-03 12:26 Denis Arefev
2025-04-11 10:03 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Denis Arefev @ 2025-04-03 12:26 UTC (permalink / raw)
To: Corentin Chary
Cc: Luke D. Jones, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel, lvc-project, stable
The value returned by acpi_evaluate_integer() is not checked,
but the result is not always successful, so it is necessary to
add a check of the returned value.
If the result remains negative during three iterations of the loop,
then the uninitialized variable 'val' will be used in the clamp_val()
macro, so it must be initialized with the current value of the 'curr'
variable.
In this case, the algorithm should be less noisy.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: b23910c2194e ("asus-laptop: Pegatron Lucid accelerometer")
Cc: stable@vger.kernel.org
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
V1 -> V2:
Added check of the return value it as Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> suggested.
Changed initialization of 'val' variable it as Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> suggested.
drivers/platform/x86/asus-laptop.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index d460dd194f19..ff674c6d0bbb 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -427,10 +427,12 @@ static int asus_pega_lucid_set(struct asus_laptop *asus, int unit, bool enable)
static int pega_acc_axis(struct asus_laptop *asus, int curr, char *method)
{
int i, delta;
- unsigned long long val;
+ acpi_status status;
+ unsigned long long val = (unsigned long long)curr;
for (i = 0; i < PEGA_ACC_RETRIES; i++) {
- acpi_evaluate_integer(asus->handle, method, NULL, &val);
-
+ status = acpi_evaluate_integer(asus->handle, method, NULL, &val);
+ if (ACPI_FAILURE(status))
+ continue;
/* The output is noisy. From reading the ASL
* dissassembly, timeout errors are returned with 1's
* in the high word, and the lack of locking around
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] asus-laptop: Fix an uninitialized variable
2025-04-03 12:26 [PATCH v2] asus-laptop: Fix an uninitialized variable Denis Arefev
@ 2025-04-11 10:03 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-04-11 10:03 UTC (permalink / raw)
To: Corentin Chary, Denis Arefev
Cc: Luke D. Jones, Hans de Goede, platform-driver-x86, linux-kernel,
lvc-project, stable
On Thu, 03 Apr 2025 15:26:01 +0300, Denis Arefev wrote:
> The value returned by acpi_evaluate_integer() is not checked,
> but the result is not always successful, so it is necessary to
> add a check of the returned value.
>
> If the result remains negative during three iterations of the loop,
> then the uninitialized variable 'val' will be used in the clamp_val()
> macro, so it must be initialized with the current value of the 'curr'
> variable.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] asus-laptop: Fix an uninitialized variable
commit: 6c683c6887e4addcd6bd1ddce08cafccb0a21e32
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-11 10:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03 12:26 [PATCH v2] asus-laptop: Fix an uninitialized variable Denis Arefev
2025-04-11 10:03 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®