Skip to contentSkip to conversation

hp_accel: Silence an uninitialized variable warning

PATCH In review Dan Carpenter 2 participants 2 messages Apr 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hp_accel: Silence an uninitialized variable warning

If acpi_evaluate_integer() fails then "lret" isn't initialized. I've tweaked the error handling to avoid this issue.

drivers/platform/x86/hp_accel.c +3 -1
index 10ce6cb..746918e 100644
@@ -127,8 +127,10 @@ static int lis3lv02d_acpi_read(struct lis3lv02d *lis3, int reg, u8 *ret)
 	arg0.integer.value = reg;
 
 	status = acpi_evaluate_integer(dev->handle, "ALRD", &args, &lret);
+	if (ACPI_FAILURE(status))
+		return -EINVAL;
 	*ret = lret;
-	return (status != AE_OK) ? -EINVAL : 0;
+	return 0;
 }
 
 /**
#1 lore raw
Quoted 4 lines · Dan Carpenter

If acpi_evaluate_integer() fails then "lret" isn't initialized. I've tweaked the error handling to avoid this issue.

Thanks Dan, I verified and queued all 3 patches to fixes for 4.6.

Quoted 18 lines
drivers/platform/x86/hp_accel.c +3 -1
index 10ce6cb..746918e 100644
@@ -127,8 +127,10 @@ static int lis3lv02d_acpi_read(struct lis3lv02d *lis3, int reg, u8 *ret)
 	arg0.integer.value = reg;
 
 	status = acpi_evaluate_integer(dev->handle, "ALRD", &args, &lret);
+	if (ACPI_FAILURE(status))
+		return -EINVAL;
 	*ret = lret;
-	return (status != AE_OK) ? -EINVAL : 0;
+	return 0;
 }
 
 /**
Signature · 2 lines
Darren Hart
Intel Open Source Technology Center