[PATCH] acpi: erst: cast size to uint64_t to clean up static analysis warning

Colin King colin.king at canonical.com
Wed Jan 24 15:12:59 UTC 2018


From: Colin Ian King <colin.king at canonical.com>

CoverityScan warns of a possible integer overflow (which is very
unlikely to happen) when multiplying 32 bit integers.  Cast the
first to the same type of variable total_length to clear up this
warning.

Detected by CoverityScan, CID#1385375 ("Unintentional integer overflow")

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/erst/erst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acpi/erst/erst.c b/src/acpi/erst/erst.c
index b9fe89e3..8ba611b7 100644
--- a/src/acpi/erst/erst.c
+++ b/src/acpi/erst/erst.c
@@ -68,7 +68,7 @@ static int erst_test1(fwts_framework *fw)
 			table->length);
 		goto done;
 	}
-	total_length = (sizeof(fwts_acpi_serialization_instruction_entries) *
+	total_length = ((uint64_t)sizeof(fwts_acpi_serialization_instruction_entries) *
 		erst->instruction_entry_count) + sizeof(fwts_acpi_table_erst);
 	if (total_length > table->length) {
 		passed = false;
-- 
2.15.1




More information about the fwts-devel mailing list