Skip to content

Commit f2e3f8d

Browse files
Denis Arefevvijay-suman
authored andcommitted
asus-laptop: Fix an uninitialized variable
commit 6c683c6887e4addcd6bd1ddce08cafccb0a21e32 upstream. 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: b23910c ("asus-laptop: Pegatron Lucid accelerometer") Cc: [email protected] Signed-off-by: Denis Arefev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 41a125eb52d6ac76c48eb32f72187e1915c12fa6) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 1d511ff commit f2e3f8d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/platform/x86/asus-laptop.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,14 @@ static int asus_pega_lucid_set(struct asus_laptop *asus, int unit, bool enable)
427427

428428
static int pega_acc_axis(struct asus_laptop *asus, int curr, char *method)
429429
{
430+
unsigned long long val = (unsigned long long)curr;
431+
acpi_status status;
430432
int i, delta;
431-
unsigned long long val;
432-
for (i = 0; i < PEGA_ACC_RETRIES; i++) {
433-
acpi_evaluate_integer(asus->handle, method, NULL, &val);
434433

434+
for (i = 0; i < PEGA_ACC_RETRIES; i++) {
435+
status = acpi_evaluate_integer(asus->handle, method, NULL, &val);
436+
if (ACPI_FAILURE(status))
437+
continue;
435438
/* The output is noisy. From reading the ASL
436439
* dissassembly, timeout errors are returned with 1's
437440
* in the high word, and the lack of locking around

0 commit comments

Comments
 (0)