Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: Use strscpy()/scnprintf() with acpi_device_name/class()

Replace strcpy() and sprintf() for acpi_device_name/class() targets
with safer variant. In one case, scnprintf() is necessary but the
rest can use strscpy().

Link: https://lore.kernel.org/r/20250407170839.2153-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

+14 -18
+2 -2
drivers/platform/x86/eeepc-laptop.c
··· 1370 1370 if (!eeepc) 1371 1371 return -ENOMEM; 1372 1372 eeepc->handle = device->handle; 1373 - strcpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME); 1374 - strcpy(acpi_device_class(device), EEEPC_ACPI_CLASS); 1373 + strscpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME); 1374 + strscpy(acpi_device_class(device), EEEPC_ACPI_CLASS); 1375 1375 device->driver_data = eeepc; 1376 1376 eeepc->device = device; 1377 1377
+2 -2
drivers/platform/x86/panasonic-laptop.c
··· 1033 1033 pcc->handle = device->handle; 1034 1034 pcc->num_sifr = num_sifr; 1035 1035 device->driver_data = pcc; 1036 - strcpy(acpi_device_name(device), ACPI_PCC_DEVICE_NAME); 1037 - strcpy(acpi_device_class(device), ACPI_PCC_CLASS); 1036 + strscpy(acpi_device_name(device), ACPI_PCC_DEVICE_NAME); 1037 + strscpy(acpi_device_class(device), ACPI_PCC_CLASS); 1038 1038 1039 1039 result = acpi_pcc_init_input(pcc); 1040 1040 if (result) {
+2 -2
drivers/platform/x86/sony-laptop.c
··· 3157 3157 struct sony_nc_value *item; 3158 3158 3159 3159 sony_nc_acpi_device = device; 3160 - strcpy(acpi_device_class(device), "sony/hotkey"); 3160 + strscpy(acpi_device_class(device), "sony/hotkey"); 3161 3161 3162 3162 sony_nc_acpi_handle = device->handle; 3163 3163 ··· 4679 4679 struct sony_pic_irq *irq, *tmp_irq; 4680 4680 4681 4681 spic_dev.acpi_dev = device; 4682 - strcpy(acpi_device_class(device), "sony/hotkey"); 4682 + strscpy(acpi_device_class(device), "sony/hotkey"); 4683 4683 sony_pic_detect_device_type(&spic_dev); 4684 4684 mutex_init(&spic_dev.lock); 4685 4685
+3 -3
drivers/platform/x86/thinkpad_acpi.c
··· 836 836 } 837 837 838 838 ibm->acpi->device->driver_data = ibm; 839 - sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", 840 - TPACPI_ACPI_EVENT_PREFIX, 841 - ibm->name); 839 + scnprintf(acpi_device_class(ibm->acpi->device), 840 + sizeof(acpi_device_class(ibm->acpi->device)), 841 + "%s/%s", TPACPI_ACPI_EVENT_PREFIX, ibm->name); 842 842 843 843 status = acpi_install_notify_handler(*ibm->acpi->handle, 844 844 ibm->acpi->type, dispatch_acpi_notify, ibm);
+2 -2
drivers/platform/x86/topstar-laptop.c
··· 296 296 if (!topstar) 297 297 return -ENOMEM; 298 298 299 - strcpy(acpi_device_name(device), "Topstar TPSACPI"); 300 - strcpy(acpi_device_class(device), TOPSTAR_LAPTOP_CLASS); 299 + strscpy(acpi_device_name(device), "Topstar TPSACPI"); 300 + strscpy(acpi_device_class(device), TOPSTAR_LAPTOP_CLASS); 301 301 device->driver_data = topstar; 302 302 topstar->device = device; 303 303
+3 -7
drivers/platform/x86/xo15-ebook.c
··· 84 84 const struct acpi_device_id *id; 85 85 struct ebook_switch *button; 86 86 struct input_dev *input; 87 - char *name, *class; 88 87 int error; 89 88 90 89 button = kzalloc(sizeof(struct ebook_switch), GFP_KERNEL); ··· 98 99 goto err_free_button; 99 100 } 100 101 101 - name = acpi_device_name(device); 102 - class = acpi_device_class(device); 103 - 104 102 id = acpi_match_acpi_device(ebook_device_ids, device); 105 103 if (!id) { 106 104 dev_err(&device->dev, "Unsupported hid\n"); ··· 105 109 goto err_free_input; 106 110 } 107 111 108 - strcpy(name, XO15_EBOOK_DEVICE_NAME); 109 - sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS); 112 + strscpy(acpi_device_name(device), XO15_EBOOK_DEVICE_NAME); 113 + strscpy(acpi_device_class(device), XO15_EBOOK_CLASS "/" XO15_EBOOK_SUBCLASS); 110 114 111 115 snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); 112 116 113 - input->name = name; 117 + input->name = acpi_device_name(device); 114 118 input->phys = button->phys; 115 119 input->id.bustype = BUS_HOST; 116 120 input->dev.parent = &device->dev;