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.

Merge tag 'acpi-6.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI fixes from Rafael Wysocki:
"These fix three ACPI driver issues and add version checks to two ACPI
table parsers:

- Call input_free_device() on failing input device registration as
necessary (and mentioned in the input subsystem documentation) in
the ACPI button driver (Kaushlendra Kumar)

- Fix use-after-free in acpi_video_switch_brightness() by canceling a
delayed work during tear-down (Yuhao Jiang)

- Use platform device for devres-related actions in the ACPI fan
driver to allow device-managed resources to be cleaned up properly
(Armin Wolf)

- Add version checks to the MRRM and SPCR table parsers (Tony Luck
and Punit Agrawal)"

* tag 'acpi-6.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPI: SPCR: Check for table version when using precise baudrate
ACPI: MRRM: Check revision of MRRM table
ACPI: fan: Use platform device for devres-related actions
ACPI: fan: Use ACPI handle when retrieving _FST
ACPI: video: Fix use-after-free in acpi_video_switch_brightness()
ACPI: button: Call input_free_device() on failing input device registration

+43 -26
+3
drivers/acpi/acpi_mrrm.c
··· 63 63 if (!mrrm) 64 64 return -ENODEV; 65 65 66 + if (mrrm->header.revision != 1) 67 + return -EINVAL; 68 + 66 69 if (mrrm->flags & ACPI_MRRM_FLAGS_REGION_ASSIGNMENT_OS) 67 70 return -EOPNOTSUPP; 68 71
+3 -1
drivers/acpi/acpi_video.c
··· 1959 1959 struct acpi_video_device *dev; 1960 1960 1961 1961 mutex_lock(&video->device_list_lock); 1962 - list_for_each_entry(dev, &video->video_device_list, entry) 1962 + list_for_each_entry(dev, &video->video_device_list, entry) { 1963 1963 acpi_video_dev_remove_notify_handler(dev); 1964 + cancel_delayed_work_sync(&dev->switch_brightness_work); 1965 + } 1964 1966 mutex_unlock(&video->device_list_lock); 1965 1967 1966 1968 acpi_video_bus_stop_devices(video);
+3 -1
drivers/acpi/button.c
··· 619 619 620 620 input_set_drvdata(input, device); 621 621 error = input_register_device(input); 622 - if (error) 622 + if (error) { 623 + input_free_device(input); 623 624 goto err_remove_fs; 625 + } 624 626 625 627 switch (device->device_type) { 626 628 case ACPI_BUS_TYPE_POWER_BUTTON:
+4 -3
drivers/acpi/fan.h
··· 49 49 }; 50 50 51 51 struct acpi_fan { 52 + acpi_handle handle; 52 53 bool acpi4; 53 54 bool has_fst; 54 55 struct acpi_fan_fif fif; ··· 60 59 struct device_attribute fine_grain_control; 61 60 }; 62 61 63 - int acpi_fan_get_fst(struct acpi_device *device, struct acpi_fan_fst *fst); 62 + int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst); 64 63 int acpi_fan_create_attributes(struct acpi_device *device); 65 64 void acpi_fan_delete_attributes(struct acpi_device *device); 66 65 67 66 #if IS_REACHABLE(CONFIG_HWMON) 68 - int devm_acpi_fan_create_hwmon(struct acpi_device *device); 67 + int devm_acpi_fan_create_hwmon(struct device *dev); 69 68 #else 70 - static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; }; 69 + static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; }; 71 70 #endif 72 71 73 72 #endif
+1 -1
drivers/acpi/fan_attr.c
··· 55 55 struct acpi_fan_fst fst; 56 56 int status; 57 57 58 - status = acpi_fan_get_fst(acpi_dev, &fst); 58 + status = acpi_fan_get_fst(acpi_dev->handle, &fst); 59 59 if (status) 60 60 return status; 61 61
+23 -13
drivers/acpi/fan_core.c
··· 44 44 return 0; 45 45 } 46 46 47 - int acpi_fan_get_fst(struct acpi_device *device, struct acpi_fan_fst *fst) 47 + int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst) 48 48 { 49 49 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 50 50 union acpi_object *obj; 51 51 acpi_status status; 52 52 int ret = 0; 53 53 54 - status = acpi_evaluate_object(device->handle, "_FST", NULL, &buffer); 55 - if (ACPI_FAILURE(status)) { 56 - dev_err(&device->dev, "Get fan state failed\n"); 57 - return -ENODEV; 58 - } 54 + status = acpi_evaluate_object(handle, "_FST", NULL, &buffer); 55 + if (ACPI_FAILURE(status)) 56 + return -EIO; 59 57 60 58 obj = buffer.pointer; 61 - if (!obj || obj->type != ACPI_TYPE_PACKAGE || 62 - obj->package.count != 3 || 63 - obj->package.elements[1].type != ACPI_TYPE_INTEGER) { 64 - dev_err(&device->dev, "Invalid _FST data\n"); 65 - ret = -EINVAL; 59 + if (!obj) 60 + return -ENODATA; 61 + 62 + if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 3) { 63 + ret = -EPROTO; 64 + goto err; 65 + } 66 + 67 + if (obj->package.elements[0].type != ACPI_TYPE_INTEGER || 68 + obj->package.elements[1].type != ACPI_TYPE_INTEGER || 69 + obj->package.elements[2].type != ACPI_TYPE_INTEGER) { 70 + ret = -EPROTO; 66 71 goto err; 67 72 } 68 73 ··· 86 81 struct acpi_fan_fst fst; 87 82 int status, i; 88 83 89 - status = acpi_fan_get_fst(device, &fst); 84 + status = acpi_fan_get_fst(device->handle, &fst); 90 85 if (status) 91 86 return status; 92 87 ··· 316 311 struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 317 312 char *name; 318 313 314 + if (!device) 315 + return -ENODEV; 316 + 319 317 fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL); 320 318 if (!fan) { 321 319 dev_err(&device->dev, "No memory for fan\n"); 322 320 return -ENOMEM; 323 321 } 322 + 323 + fan->handle = device->handle; 324 324 device->driver_data = fan; 325 325 platform_set_drvdata(pdev, fan); 326 326 ··· 347 337 } 348 338 349 339 if (fan->has_fst) { 350 - result = devm_acpi_fan_create_hwmon(device); 340 + result = devm_acpi_fan_create_hwmon(&pdev->dev); 351 341 if (result) 352 342 return result; 353 343
+5 -6
drivers/acpi/fan_hwmon.c
··· 93 93 static int acpi_fan_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, 94 94 int channel, long *val) 95 95 { 96 - struct acpi_device *adev = to_acpi_device(dev->parent); 97 96 struct acpi_fan *fan = dev_get_drvdata(dev); 98 97 struct acpi_fan_fps *fps; 99 98 struct acpi_fan_fst fst; 100 99 int ret; 101 100 102 - ret = acpi_fan_get_fst(adev, &fst); 101 + ret = acpi_fan_get_fst(fan->handle, &fst); 103 102 if (ret < 0) 104 103 return ret; 105 104 ··· 166 167 .info = acpi_fan_hwmon_info, 167 168 }; 168 169 169 - int devm_acpi_fan_create_hwmon(struct acpi_device *device) 170 + int devm_acpi_fan_create_hwmon(struct device *dev) 170 171 { 171 - struct acpi_fan *fan = acpi_driver_data(device); 172 + struct acpi_fan *fan = dev_get_drvdata(dev); 172 173 struct device *hdev; 173 174 174 - hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan, 175 - &acpi_fan_hwmon_chip_info, NULL); 175 + hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info, 176 + NULL); 176 177 return PTR_ERR_OR_ZERO(hdev); 177 178 }
+1 -1
drivers/acpi/spcr.c
··· 155 155 * Baud Rate field. If this field is zero or not present, Configured 156 156 * Baud Rate is used. 157 157 */ 158 - if (table->precise_baudrate) 158 + if (table->header.revision >= 4 && table->precise_baudrate) 159 159 baud_rate = table->precise_baudrate; 160 160 else switch (table->baud_rate) { 161 161 case 0: