summaryrefslogtreecommitdiff
path: root/lib/acpi
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2024-10-30 14:11:46 +0100
committerTom Rini <trini@konsulko.com>2024-11-01 13:33:57 -0600
commit99ce74a41baede05b20639f3839588b3a9678df8 (patch)
treeb89555bef3230ba608e99df7de7499f9a648a540 /lib/acpi
parente61ea9f2e5d2967826c2c6e3edba961064fbbaa1 (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 <patrick.rudolph@9elements.com>
Diffstat (limited to 'lib/acpi')
-rw-r--r--lib/acpi/acpi_table.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 6473d95c102..150f75027a5 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 */
@@ -495,7 +495,7 @@ static int acpi_write_spcr(struct acpi_ctx *ctx, const struct acpi_writer *entry
break;
}
- debug("UART type %u @ %lx\n", spcr->interface_type, serial_address);
+ debug("UART type %u @ %llx\n", spcr->interface_type, serial_address);
/* Fill GAS */
spcr->serial_port.space_id = space_id;