Skip to content

Commit f4e087c

Browse files
committed
Merge tag 'acpi-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "These address a device ID bounds check error in the device enumeration code and fix a mistake in the documentation. Specifics: - Harden the ACPI device enumeration code against device ID length overflows to address a Linux VM cash on Hyper-V (Dexuan Cui). - Fix a mistake in the documentation of error type values for PCIe errors (Qiuxu Zhuo)" * tag 'acpi-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: Documentation: ACPI: EINJ: Fix error type values for PCIe errors ACPI: scan: Harden acpi_device_add() against device ID overflows
2 parents dcda487 + 179892a commit f4e087c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Documentation/firmware-guide/acpi/apei/einj.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ The following files belong to it:
5050
0x00000010 Memory Uncorrectable non-fatal
5151
0x00000020 Memory Uncorrectable fatal
5252
0x00000040 PCI Express Correctable
53-
0x00000080 PCI Express Uncorrectable fatal
54-
0x00000100 PCI Express Uncorrectable non-fatal
53+
0x00000080 PCI Express Uncorrectable non-fatal
54+
0x00000100 PCI Express Uncorrectable fatal
5555
0x00000200 Platform Correctable
5656
0x00000400 Platform Uncorrectable non-fatal
5757
0x00000800 Platform Uncorrectable fatal

drivers/acpi/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void acpi_scan_table_handler(u32 event, void *table, void *context);
9797
extern struct list_head acpi_bus_id_list;
9898

9999
struct acpi_device_bus_id {
100-
char bus_id[15];
100+
const char *bus_id;
101101
unsigned int instance_no;
102102
struct list_head node;
103103
};

drivers/acpi/scan.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static void acpi_device_del(struct acpi_device *device)
486486
acpi_device_bus_id->instance_no--;
487487
else {
488488
list_del(&acpi_device_bus_id->node);
489+
kfree_const(acpi_device_bus_id->bus_id);
489490
kfree(acpi_device_bus_id);
490491
}
491492
break;
@@ -674,7 +675,14 @@ int acpi_device_add(struct acpi_device *device,
674675
}
675676
if (!found) {
676677
acpi_device_bus_id = new_bus_id;
677-
strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device));
678+
acpi_device_bus_id->bus_id =
679+
kstrdup_const(acpi_device_hid(device), GFP_KERNEL);
680+
if (!acpi_device_bus_id->bus_id) {
681+
pr_err(PREFIX "Memory allocation error for bus id\n");
682+
result = -ENOMEM;
683+
goto err_free_new_bus_id;
684+
}
685+
678686
acpi_device_bus_id->instance_no = 0;
679687
list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
680688
}
@@ -709,6 +717,11 @@ int acpi_device_add(struct acpi_device *device,
709717
if (device->parent)
710718
list_del(&device->node);
711719
list_del(&device->wakeup_list);
720+
721+
err_free_new_bus_id:
722+
if (!found)
723+
kfree(new_bus_id);
724+
712725
mutex_unlock(&acpi_device_lock);
713726

714727
err_detach:

0 commit comments

Comments
 (0)