Skip to content

Commit 376b0fb

Browse files
keesrafaeljw
authored andcommitted
ACPICA: acpi_resource_irq: Replace 1-element arrays with flexible array
ACPICA commit bfdd3446e7caf795c85c70326c137023942972c5 Similar to "Replace one-element array with flexible-array", replace the 1-element array with a proper flexible array member as defined by C99. This allows the code to operate without tripping compile-time and run- time bounds checkers (e.g. via __builtin_object_size(), -fsanitize=bounds, and/or -fstrict-flex-arrays=3). Note that the spec requires there be at least one interrupt, so use a union to keep space allocated for this. The only binary change in .text and .data sections is some rearrangement by the compiler of acpi_dm_address_common(), but appears to be harmless. Link: acpica/acpica@bfdd3446 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2a85fc5 commit 376b0fb

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/acpi/acpica/amlresrc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ struct aml_resource_address16 {
261261
struct aml_resource_extended_irq {
262262
AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
263263
u8 interrupt_count;
264-
u32 interrupts[1];
264+
union {
265+
u32 interrupt;
266+
ACPI_FLEX_ARRAY(u32, interrupts);
267+
};
265268
/* res_source_index, res_source optional fields follow */
266269
};
267270

include/acpi/acrestyp.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ struct acpi_resource_irq {
142142
u8 shareable;
143143
u8 wake_capable;
144144
u8 interrupt_count;
145-
u8 interrupts[1];
145+
union {
146+
u8 interrupt;
147+
ACPI_FLEX_ARRAY(u8, interrupts);
148+
};
146149
};
147150

148151
struct acpi_resource_dma {
@@ -335,7 +338,10 @@ struct acpi_resource_extended_irq {
335338
u8 wake_capable;
336339
u8 interrupt_count;
337340
struct acpi_resource_source resource_source;
338-
u32 interrupts[1];
341+
union {
342+
u32 interrupt;
343+
ACPI_FLEX_ARRAY(u32, interrupts);
344+
};
339345
};
340346

341347
struct acpi_resource_generic_register {

0 commit comments

Comments
 (0)