summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Rudolph <[email protected]>2024-10-28 09:08:35 +0100
committerTom Rini <[email protected]>2024-10-28 16:50:26 -0600
commite1c3c720e780eed6647796d69dca6184640234a5 (patch)
tree1378ae3213921b5c98244b089ac9526006ec4fa3
parentf2533fb04893467cc64fd5e31158a8c861c0a883 (diff)
acpi_table: Fix coverity defect in acpi_write_spcr
Fix "Integer handling issues (SIGN_EXTENSION)" in newly added code: Cast serial_info.reg_offset to u64 to prevent an integer overflow when shifted too many bits to the left. Currently this never happens as the shift is supposed to be less than 4. Signed-off-by: Patrick Rudolph <[email protected]> Reviewed-by: Moritz Fischer <[email protected]>
-rw-r--r--lib/acpi/acpi_table.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 6473d95c102..b9e12228fda 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -420,7 +420,7 @@ int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
static int acpi_write_spcr(struct acpi_ctx *ctx, const struct acpi_writer *entry)
{
struct serial_device_info serial_info = {0};
- ulong serial_address, serial_offset;
+ u64 serial_address, serial_offset;
struct acpi_table_header *header;
struct acpi_spcr *spcr;
struct udevice *dev;
@@ -473,7 +473,7 @@ static int acpi_write_spcr(struct acpi_ctx *ctx, const struct acpi_writer *entry
}
serial_width = serial_info.reg_width * 8;
- serial_offset = serial_info.reg_offset << serial_info.reg_shift;
+ serial_offset = ((u64)serial_info.reg_offset) << serial_info.reg_shift;
serial_address = serial_info.addr + serial_offset;
/* Encode register access size */