GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ACPICA: Apply pack(1) to union aml_resource · frank-w/BPI-Router-Linux@7efa785

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • drivers/acpi/acpica
    • amlresrc.h
    • rsaddr.c
    • rscalc.c
    • rslist.c
    • utresrc.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎drivers/acpi/acpica/amlresrc.h‎

Copy file name to clipboardExpand all lines: drivers/acpi/acpica/amlresrc.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,6 @@ struct aml_resource_pin_group_config {
504504

505505
#define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION 1 /* ACPI 6.2 */
506506

507-
/* restore default alignment */
508-
509-
#pragma pack()
510-
511507
/* Union of all resource descriptors, so we can allocate the worst case */
512508

513509
union aml_resource {
@@ -562,6 +558,10 @@ union aml_resource {
562558
u8 byte_item;
563559
};
564560

561+
/* restore default alignment */
562+
563+
#pragma pack()
564+
565565
/* Interfaces used by both the disassembler and compiler */
566566

567567
void
Collapse file

‎drivers/acpi/acpica/rsaddr.c‎

Copy file name to clipboardExpand all lines: drivers/acpi/acpica/rsaddr.c
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,13 @@ u8
272272
acpi_rs_get_address_common(struct acpi_resource *resource,
273273
union aml_resource *aml)
274274
{
275-
struct aml_resource_address address;
276-
277275
ACPI_FUNCTION_ENTRY();
278276

279-
/* Avoid undefined behavior: member access within misaligned address */
280-
281-
memcpy(&address, aml, sizeof(address));
282-
283277
/* Validate the Resource Type */
284278

285-
if ((address.resource_type > 2) &&
286-
(address.resource_type < 0xC0) && (address.resource_type != 0x0A)) {
279+
if ((aml->address.resource_type > 2) &&
280+
(aml->address.resource_type < 0xC0) &&
281+
(aml->address.resource_type != 0x0A)) {
287282
return (FALSE);
288283
}
289284

@@ -304,7 +299,7 @@ acpi_rs_get_address_common(struct acpi_resource *resource,
304299
/* Generic resource type, just grab the type_specific byte */
305300

306301
resource->data.address.info.type_specific =
307-
address.specific_flags;
302+
aml->address.specific_flags;
308303
}
309304

310305
return (TRUE);
Collapse file

‎drivers/acpi/acpica/rscalc.c‎

Copy file name to clipboardExpand all lines: drivers/acpi/acpica/rscalc.c
+5-17Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,12 @@ acpi_rs_get_list_length(u8 *aml_buffer,
608608

609609
case ACPI_RESOURCE_NAME_SERIAL_BUS:{
610610

611-
/* Avoid undefined behavior: member access within misaligned address */
612-
613-
struct aml_resource_common_serialbus
614-
common_serial_bus;
615-
memcpy(&common_serial_bus, aml_resource,
616-
sizeof(common_serial_bus));
617-
618611
minimum_aml_resource_length =
619612
acpi_gbl_resource_aml_serial_bus_sizes
620-
[common_serial_bus.type];
613+
[aml_resource->common_serial_bus.type];
621614
extra_struct_bytes +=
622-
common_serial_bus.resource_length -
615+
aml_resource->common_serial_bus.
616+
resource_length -
623617
minimum_aml_resource_length;
624618
break;
625619
}
@@ -688,16 +682,10 @@ acpi_rs_get_list_length(u8 *aml_buffer,
688682
*/
689683
if (acpi_ut_get_resource_type(aml_buffer) ==
690684
ACPI_RESOURCE_NAME_SERIAL_BUS) {
691-
692-
/* Avoid undefined behavior: member access within misaligned address */
693-
694-
struct aml_resource_common_serialbus common_serial_bus;
695-
memcpy(&common_serial_bus, aml_resource,
696-
sizeof(common_serial_bus));
697-
698685
buffer_size =
699686
acpi_gbl_resource_struct_serial_bus_sizes
700-
[common_serial_bus.type] + extra_struct_bytes;
687+
[aml_resource->common_serial_bus.type] +
688+
extra_struct_bytes;
701689
} else {
702690
buffer_size =
703691
acpi_gbl_resource_struct_sizes[resource_index] +
Collapse file

‎drivers/acpi/acpica/rslist.c‎

Copy file name to clipboardExpand all lines: drivers/acpi/acpica/rslist.c
+3-9Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,15 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
5555
aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
5656

5757
if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_SERIAL_BUS) {
58-
59-
/* Avoid undefined behavior: member access within misaligned address */
60-
61-
struct aml_resource_common_serialbus common_serial_bus;
62-
memcpy(&common_serial_bus, aml_resource,
63-
sizeof(common_serial_bus));
64-
65-
if (common_serial_bus.type > AML_RESOURCE_MAX_SERIALBUSTYPE) {
58+
if (aml_resource->common_serial_bus.type >
59+
AML_RESOURCE_MAX_SERIALBUSTYPE) {
6660
conversion_table = NULL;
6761
} else {
6862
/* This is an I2C, SPI, UART, or CSI2 serial_bus descriptor */
6963

7064
conversion_table =
7165
acpi_gbl_convert_resource_serial_bus_dispatch
72-
[common_serial_bus.type];
66+
[aml_resource->common_serial_bus.type];
7367
}
7468
} else {
7569
conversion_table =
Collapse file

‎drivers/acpi/acpica/utresrc.c‎

Copy file name to clipboardExpand all lines: drivers/acpi/acpica/utresrc.c
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,16 @@ acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
361361
aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
362362
if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) {
363363

364-
/* Avoid undefined behavior: member access within misaligned address */
365-
366-
struct aml_resource_common_serialbus common_serial_bus;
367-
memcpy(&common_serial_bus, aml_resource,
368-
sizeof(common_serial_bus));
369-
370364
/* Validate the bus_type field */
371365

372-
if ((common_serial_bus.type == 0) ||
373-
(common_serial_bus.type > AML_RESOURCE_MAX_SERIALBUSTYPE)) {
366+
if ((aml_resource->common_serial_bus.type == 0) ||
367+
(aml_resource->common_serial_bus.type >
368+
AML_RESOURCE_MAX_SERIALBUSTYPE)) {
374369
if (walk_state) {
375370
ACPI_ERROR((AE_INFO,
376371
"Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
377-
common_serial_bus.type));
372+
aml_resource->common_serial_bus.
373+
type));
378374
}
379375
return (AE_AML_INVALID_RESOURCE_TYPE);
380376
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.