Skip to contentSkip to conversation

tpm/ppi: fix return type in tpm_show_ppi_response()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 4, 2022 – Aug 6, 2022

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

PATCH 1/1 tpm/ppi: fix return type in tpm_show_ppi_response()

This "status" is declared as type acpi_status but it is never used to store any acpi_statuses, only int.

The tpm_show_ppi_response() function returns ssize_t (signed long) and acpi_status is unsigned int. That means that negative error codes will be type promoted to large positive values.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index 40018a73b3cb..240df925c38c 100644
@@ -222,7 +222,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	int status = -EINVAL;
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Dan Carpenter

This "status" is declared as type acpi_status but it is never used to store any acpi_statuses, only int.

The tpm_show_ppi_response() function returns ssize_t (signed long) and acpi_status is unsigned int. That means that negative error codes will be type promoted to large positive values.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index 40018a73b3cb..240df925c38c 100644
@@ -222,7 +222,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	int status = -EINVAL;
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.35.1

BR, Jarkko