Pull more ACPI updates from Rafael Wysocki: "These are fixes and cleanup on top of the previously merged ACPI material. Specifics: - Avoid out-of-bounds access when parsing _CPC data (Rafael Wysocki) - Change default error code and clean up debug messages in ACPI CPPC probe (Rafael Wysocki) - Replace usage of found with dedicated list iterator variable in the ACPI IPMI driver (Jakob Koschel) - Clean up variable name confusion in APEI (Jakob Koschel) - Make LAPIC_ADDR_OVR address readable in a message parsed during MADT parsing (Vasant Hegde)" * tag 'acpi-5.18-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: CPPC: Change default error code and clean up debug messages in probe ACPI: CPPC: Avoid out of bounds access when parsing _CPC data ACPI: tables: Make LAPIC_ADDR_OVR address readable in message ACPI: IPMI: replace usage of found with dedicated list iterator variable ACPI, APEI: Use the correct variable for sizeof()
Unified · Split
| @@ -353,29 +353,27 @@ static void ipmi_flush_tx_msg(struct acpi_ipmi_device *ipmi) · 352 unmodified lines | |||
| 353 | static void ipmi_cancel_tx_msg(struct acpi_ipmi_device *ipmi, | 353 | static void ipmi_cancel_tx_msg(struct acpi_ipmi_device *ipmi, |
| 354 | struct acpi_ipmi_msg *msg) | 354 | struct acpi_ipmi_msg *msg) |
| 355 | { | 355 | { |
| 356 | struct acpi_ipmi_msg *tx_msg, *temp; | 356 | struct acpi_ipmi_msg *tx_msg = NULL, *iter, *temp; |
| 357 | bool msg_found = false; | ||
| 358 | unsigned long flags; | 357 | unsigned long flags; |
| 359 | 358 | ||
| 360 | spin_lock_irqsave(&ipmi->tx_msg_lock, flags); | 359 | spin_lock_irqsave(&ipmi->tx_msg_lock, flags); |
| 361 | list_for_each_entry_safe(tx_msg, temp, &ipmi->tx_msg_list, head) { | 360 | list_for_each_entry_safe(iter, temp, &ipmi->tx_msg_list, head) { |
| 362 | if (msg == tx_msg) { | 361 | if (msg == iter) { |
| 363 | msg_found = true; | 362 | tx_msg = iter; |
| 364 | list_del(&tx_msg->head); | 363 | list_del(&iter->head); |
| 365 | break; | 364 | break; |
| 366 | } | 365 | } |
| 367 | } | 366 | } |
| 368 | spin_unlock_irqrestore(&ipmi->tx_msg_lock, flags); | 367 | spin_unlock_irqrestore(&ipmi->tx_msg_lock, flags); |
| 369 | 368 | ||
| 370 | if (msg_found) | 369 | if (tx_msg) |
| 371 | acpi_ipmi_msg_put(tx_msg); | 370 | acpi_ipmi_msg_put(tx_msg); |
| 372 | } | 371 | } |
| 373 | 372 | ||
| 374 | static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) | 373 | static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) |
| 375 | { | 374 | { |
| 376 | struct acpi_ipmi_device *ipmi_device = user_msg_data; | 375 | struct acpi_ipmi_device *ipmi_device = user_msg_data; |
| 377 | bool msg_found = false; | 376 | struct acpi_ipmi_msg *tx_msg = NULL, *iter, *temp; |
| 378 | struct acpi_ipmi_msg *tx_msg, *temp; | ||
| 379 | struct device *dev = ipmi_device->dev; | 377 | struct device *dev = ipmi_device->dev; |
| 380 | unsigned long flags; | 378 | unsigned long flags; |
| 381 | 379 | ||
| @@ -387,16 +385,16 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) · 5 unmodified lines | |||
| 387 | } | 385 | } |
| 388 | 386 | ||
| 389 | spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags); | 387 | spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags); |
| 390 | list_for_each_entry_safe(tx_msg, temp, &ipmi_device->tx_msg_list, head) { | 388 | list_for_each_entry_safe(iter, temp, &ipmi_device->tx_msg_list, head) { |
| 391 | if (msg->msgid == tx_msg->tx_msgid) { | 389 | if (msg->msgid == iter->tx_msgid) { |
| 392 | msg_found = true; | 390 | tx_msg = iter; |
| 393 | list_del(&tx_msg->head); | 391 | list_del(&iter->head); |
| 394 | break; | 392 | break; |
| 395 | } | 393 | } |
| 396 | } | 394 | } |
| 397 | spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags); | 395 | spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags); |
| 398 | 396 | ||
| 399 | if (!msg_found) { | 397 | if (!tx_msg) { |
| 400 | dev_warn(dev, | 398 | dev_warn(dev, |
| 401 | "Unexpected response (msg id %ld) is returned.\n", | 399 | "Unexpected response (msg id %ld) is returned.\n", |
| 402 | msg->msgid); | 400 | msg->msgid); |
| @@ -482,15 +480,14 @@ err_ref: · 79 unmodified lines | |||
| 482 | 480 | ||
| 483 | static void ipmi_bmc_gone(int iface) | 481 | static void ipmi_bmc_gone(int iface) |
| 484 | { | 482 | { |
| 485 | struct acpi_ipmi_device *ipmi_device, *temp; | 483 | struct acpi_ipmi_device *ipmi_device = NULL, *iter, *temp; |
| 486 | bool dev_found = false; | ||
| 487 | 484 | ||
| 488 | mutex_lock(&driver_data.ipmi_lock); | 485 | mutex_lock(&driver_data.ipmi_lock); |
| 489 | list_for_each_entry_safe(ipmi_device, temp, | 486 | list_for_each_entry_safe(iter, temp, |
| 490 | &driver_data.ipmi_devices, head) { | 487 | &driver_data.ipmi_devices, head) { |
| 491 | if (ipmi_device->ipmi_ifnum != iface) { | 488 | if (iter->ipmi_ifnum != iface) { |
| 492 | dev_found = true; | 489 | ipmi_device = iter; |
| 493 | __ipmi_dev_kill(ipmi_device); | 490 | __ipmi_dev_kill(iter); |
| 494 | break; | 491 | break; |
| 495 | } | 492 | } |
| 496 | } | 493 | } |
| @@ -500,7 +497,7 @@ static void ipmi_bmc_gone(int iface) · 3 unmodified lines | |||
| 500 | struct acpi_ipmi_device, head); | 497 | struct acpi_ipmi_device, head); |
| 501 | mutex_unlock(&driver_data.ipmi_lock); | 498 | mutex_unlock(&driver_data.ipmi_lock); |
| 502 | 499 | ||
| 503 | if (dev_found) { | 500 | if (ipmi_device) { |
| 504 | ipmi_flush_tx_msg(ipmi_device); | 501 | ipmi_flush_tx_msg(ipmi_device); |
| 505 | acpi_ipmi_dev_put(ipmi_device); | 502 | acpi_ipmi_dev_put(ipmi_device); |
| 506 | } | 503 | } |
| @@ -319,7 +319,7 @@ repeat: · 318 unmodified lines | |||
| 319 | if (res_ins) | 319 | if (res_ins) |
| 320 | list_add(&res_ins->list, res_list); | 320 | list_add(&res_ins->list, res_list); |
| 321 | else { | 321 | else { |
| 322 | res_ins = kmalloc(sizeof(*res), GFP_KERNEL); | 322 | res_ins = kmalloc(sizeof(*res_ins), GFP_KERNEL); |
| 323 | if (!res_ins) | 323 | if (!res_ins) |
| 324 | return -ENOMEM; | 324 | return -ENOMEM; |
| 325 | res_ins->start = start; | 325 | res_ins->start = start; |
| @@ -654,7 +654,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 653 unmodified lines | |||
| 654 | unsigned int num_ent, i, cpc_rev; | 654 | unsigned int num_ent, i, cpc_rev; |
| 655 | int pcc_subspace_id = -1; | 655 | int pcc_subspace_id = -1; |
| 656 | acpi_status status; | 656 | acpi_status status; |
| 657 | int ret = -EFAULT; | 657 | int ret = -ENODATA; |
| 658 | 658 | ||
| 659 | if (osc_sb_cppc_not_supported) | 659 | if (osc_sb_cppc_not_supported) |
| 660 | return -ENODEV; | 660 | return -ENODEV; |
| @@ -679,9 +679,14 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 18 unmodified lines | |||
| 679 | cpc_obj = &out_obj->package.elements[0]; | 679 | cpc_obj = &out_obj->package.elements[0]; |
| 680 | if (cpc_obj->type == ACPI_TYPE_INTEGER) { | 680 | if (cpc_obj->type == ACPI_TYPE_INTEGER) { |
| 681 | num_ent = cpc_obj->integer.value; | 681 | num_ent = cpc_obj->integer.value; |
| 682 | if (num_ent <= 1) { | ||
| 683 | pr_debug("Unexpected _CPC NumEntries value (%d) for CPU:%d\n", | ||
| 684 | num_ent, pr->id); | ||
| 685 | goto out_free; | ||
| 686 | } | ||
| 682 | } else { | 687 | } else { |
| 683 | pr_debug("Unexpected entry type(%d) for NumEntries\n", | 688 | pr_debug("Unexpected _CPC NumEntries entry type (%d) for CPU:%d\n", |
| 684 | cpc_obj->type); | 689 | cpc_obj->type, pr->id); |
| 685 | goto out_free; | 690 | goto out_free; |
| 686 | } | 691 | } |
| 687 | cpc_ptr->num_entries = num_ent; | 692 | cpc_ptr->num_entries = num_ent; |
| @@ -691,8 +696,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 3 unmodified lines | |||
| 691 | if (cpc_obj->type == ACPI_TYPE_INTEGER) { | 696 | if (cpc_obj->type == ACPI_TYPE_INTEGER) { |
| 692 | cpc_rev = cpc_obj->integer.value; | 697 | cpc_rev = cpc_obj->integer.value; |
| 693 | } else { | 698 | } else { |
| 694 | pr_debug("Unexpected entry type(%d) for Revision\n", | 699 | pr_debug("Unexpected _CPC Revision entry type (%d) for CPU:%d\n", |
| 695 | cpc_obj->type); | 700 | cpc_obj->type, pr->id); |
| 696 | goto out_free; | 701 | goto out_free; |
| 697 | } | 702 | } |
| 698 | cpc_ptr->version = cpc_rev; | 703 | cpc_ptr->version = cpc_rev; |
| @@ -723,7 +728,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 24 unmodified lines | |||
| 723 | if (pcc_data_alloc(pcc_subspace_id)) | 728 | if (pcc_data_alloc(pcc_subspace_id)) |
| 724 | goto out_free; | 729 | goto out_free; |
| 725 | } else if (pcc_subspace_id != gas_t->access_width) { | 730 | } else if (pcc_subspace_id != gas_t->access_width) { |
| 726 | pr_debug("Mismatched PCC ids.\n"); | 731 | pr_debug("Mismatched PCC ids in _CPC for CPU:%d\n", |
| 732 | pr->id); | ||
| 727 | goto out_free; | 733 | goto out_free; |
| 728 | } | 734 | } |
| 729 | } else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { | 735 | } else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { |
| @@ -742,20 +748,21 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 12 unmodified lines | |||
| 742 | * SystemIO doesn't implement 64-bit | 748 | * SystemIO doesn't implement 64-bit |
| 743 | * registers. | 749 | * registers. |
| 744 | */ | 750 | */ |
| 745 | pr_debug("Invalid access width %d for SystemIO register\n", | 751 | pr_debug("Invalid access width %d for SystemIO register in _CPC\n", |
| 746 | gas_t->access_width); | 752 | gas_t->access_width); |
| 747 | goto out_free; | 753 | goto out_free; |
| 748 | } | 754 | } |
| 749 | if (gas_t->address & OVER_16BTS_MASK) { | 755 | if (gas_t->address & OVER_16BTS_MASK) { |
| 750 | /* SystemIO registers use 16-bit integer addresses */ | 756 | /* SystemIO registers use 16-bit integer addresses */ |
| 751 | pr_debug("Invalid IO port %llu for SystemIO register\n", | 757 | pr_debug("Invalid IO port %llu for SystemIO register in _CPC\n", |
| 752 | gas_t->address); | 758 | gas_t->address); |
| 753 | goto out_free; | 759 | goto out_free; |
| 754 | } | 760 | } |
| 755 | } else { | 761 | } else { |
| 756 | if (gas_t->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_supported()) { | 762 | if (gas_t->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_supported()) { |
| 757 | /* Support only PCC, SystemMemory, SystemIO, and FFH type regs. */ | 763 | /* Support only PCC, SystemMemory, SystemIO, and FFH type regs. */ |
| 758 | pr_debug("Unsupported register type: %d\n", gas_t->space_id); | 764 | pr_debug("Unsupported register type (%d) in _CPC\n", |
| 765 | gas_t->space_id); | ||
| 759 | goto out_free; | 766 | goto out_free; |
| 760 | } | 767 | } |
| 761 | } | 768 | } |
| @@ -763,7 +770,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) · 1 unmodified line | |||
| 763 | cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER; | 770 | cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER; |
| 764 | memcpy(&cpc_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, sizeof(*gas_t)); | 771 | memcpy(&cpc_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, sizeof(*gas_t)); |
| 765 | } else { | 772 | } else { |
| 766 | pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, pr->id); | 773 | pr_debug("Invalid entry type (%d) in _CPC for CPU:%d\n", |
| 774 | i, pr->id); | ||
| 767 | goto out_free; | 775 | goto out_free; |
| 768 | } | 776 | } |
| 769 | } | 777 | } |
| @@ -151,8 +151,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) · 150 unmodified lines | |||
| 151 | { | 151 | { |
| 152 | struct acpi_madt_local_apic_override *p = | 152 | struct acpi_madt_local_apic_override *p = |
| 153 | (struct acpi_madt_local_apic_override *)header; | 153 | (struct acpi_madt_local_apic_override *)header; |
| 154 | pr_info("LAPIC_ADDR_OVR (address[%p])\n", | 154 | pr_info("LAPIC_ADDR_OVR (address[0x%llx])\n", |
| 155 | (void *)(unsigned long)p->address); | 155 | p->address); |
| 156 | } | 156 | } |
| 157 | break; | 157 | break; |
| 158 | 158 | ||