Skip to content

Commit 93003de

Browse files
committed
Merge branches 'acpi-scan', 'acpi-osl', 'acpi-osi' and 'acpi-tables'
Merge ACPI updates related to device enumeration, low-level interface for ACPICA (OSL), _OSI handling and table parsing for 6.7-rc1: - Use the acpi_device_is_present() helper in more places and rename acpi_scan_device_not_present() to be about enumeration (James Morse). - Add __printf format attribute to acpi_os_vprintf() (Su Hui). - Clean up departures from kernel coding style in the low-level interface for ACPICA (Jonathan Bergh). - Replace strncpy() with strscpy() in acpi_osi_setup() (Justin Stitt). - Fail FPDT parsing on zero length records and add proper handling for fpdt_process_subtable() to acpi_init_fpdt() (Vasily Khoruzhick). * acpi-scan: ACPI: scan: Rename acpi_scan_device_not_present() to be about enumeration ACPI: scan: Use the acpi_device_is_present() helper in more places * acpi-osl: ACPI: OSL: Add empty lines after local variable declarations ACPI: OSL: Remove redundant parentheses in return statements ACPI: OSL: Fix up white space in parameter lists ACPI: OSL: add __printf format attribute to acpi_os_vprintf() * acpi-osi: ACPI: OSI: refactor deprecated strncpy() * acpi-tables: ACPI: FPDT: properly handle invalid FPDT subtables
5 parents d633c38 + 8c6fdbd + a1da3b7 + f1fce1c + a83c68a commit 93003de

File tree

4 files changed

+60
-27
lines changed

4 files changed

+60
-27
lines changed

drivers/acpi/acpi_fpdt.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,19 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)
194194
record_header = (void *)subtable_header + offset;
195195
offset += record_header->length;
196196

197+
if (!record_header->length) {
198+
pr_err(FW_BUG "Zero-length record found in FPTD.\n");
199+
result = -EINVAL;
200+
goto err;
201+
}
202+
197203
switch (record_header->type) {
198204
case RECORD_S3_RESUME:
199205
if (subtable_type != SUBTABLE_S3PT) {
200206
pr_err(FW_BUG "Invalid record %d for subtable %s\n",
201207
record_header->type, signature);
202-
return -EINVAL;
208+
result = -EINVAL;
209+
goto err;
203210
}
204211
if (record_resume) {
205212
pr_err("Duplicate resume performance record found.\n");
@@ -208,7 +215,7 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)
208215
record_resume = (struct resume_performance_record *)record_header;
209216
result = sysfs_create_group(fpdt_kobj, &resume_attr_group);
210217
if (result)
211-
return result;
218+
goto err;
212219
break;
213220
case RECORD_S3_SUSPEND:
214221
if (subtable_type != SUBTABLE_S3PT) {
@@ -223,13 +230,14 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)
223230
record_suspend = (struct suspend_performance_record *)record_header;
224231
result = sysfs_create_group(fpdt_kobj, &suspend_attr_group);
225232
if (result)
226-
return result;
233+
goto err;
227234
break;
228235
case RECORD_BOOT:
229236
if (subtable_type != SUBTABLE_FBPT) {
230237
pr_err(FW_BUG "Invalid %d for subtable %s\n",
231238
record_header->type, signature);
232-
return -EINVAL;
239+
result = -EINVAL;
240+
goto err;
233241
}
234242
if (record_boot) {
235243
pr_err("Duplicate boot performance record found.\n");
@@ -238,7 +246,7 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)
238246
record_boot = (struct boot_performance_record *)record_header;
239247
result = sysfs_create_group(fpdt_kobj, &boot_attr_group);
240248
if (result)
241-
return result;
249+
goto err;
242250
break;
243251

244252
default:
@@ -247,6 +255,18 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)
247255
}
248256
}
249257
return 0;
258+
259+
err:
260+
if (record_boot)
261+
sysfs_remove_group(fpdt_kobj, &boot_attr_group);
262+
263+
if (record_suspend)
264+
sysfs_remove_group(fpdt_kobj, &suspend_attr_group);
265+
266+
if (record_resume)
267+
sysfs_remove_group(fpdt_kobj, &resume_attr_group);
268+
269+
return result;
250270
}
251271

252272
static int __init acpi_init_fpdt(void)
@@ -255,6 +275,7 @@ static int __init acpi_init_fpdt(void)
255275
struct acpi_table_header *header;
256276
struct fpdt_subtable_entry *subtable;
257277
u32 offset = sizeof(*header);
278+
int result;
258279

259280
status = acpi_get_table(ACPI_SIG_FPDT, 0, &header);
260281

@@ -263,17 +284,19 @@ static int __init acpi_init_fpdt(void)
263284

264285
fpdt_kobj = kobject_create_and_add("fpdt", acpi_kobj);
265286
if (!fpdt_kobj) {
266-
acpi_put_table(header);
267-
return -ENOMEM;
287+
result = -ENOMEM;
288+
goto err_nomem;
268289
}
269290

270291
while (offset < header->length) {
271292
subtable = (void *)header + offset;
272293
switch (subtable->type) {
273294
case SUBTABLE_FBPT:
274295
case SUBTABLE_S3PT:
275-
fpdt_process_subtable(subtable->address,
296+
result = fpdt_process_subtable(subtable->address,
276297
subtable->type);
298+
if (result)
299+
goto err_subtable;
277300
break;
278301
default:
279302
/* Other types are reserved in ACPI 6.4 spec. */
@@ -282,6 +305,12 @@ static int __init acpi_init_fpdt(void)
282305
offset += sizeof(*subtable);
283306
}
284307
return 0;
308+
err_subtable:
309+
kobject_put(fpdt_kobj);
310+
311+
err_nomem:
312+
acpi_put_table(header);
313+
return result;
285314
}
286315

287316
fs_initcall(acpi_init_fpdt);

drivers/acpi/osi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void __init acpi_osi_setup(char *str)
110110
break;
111111
} else if (osi->string[0] == '\0') {
112112
osi->enable = enable;
113-
strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
113+
strscpy(osi->string, str, OSI_STRING_LENGTH_MAX);
114114
break;
115115
}
116116
}

drivers/acpi/osl.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void acpi_os_printf(const char *fmt, ...)
149149
}
150150
EXPORT_SYMBOL(acpi_os_printf);
151151

152-
void acpi_os_vprintf(const char *fmt, va_list args)
152+
void __printf(1, 0) acpi_os_vprintf(const char *fmt, va_list args)
153153
{
154154
static char buffer[512];
155155

@@ -493,7 +493,7 @@ EXPORT_SYMBOL(acpi_os_unmap_generic_address);
493493

494494
#ifdef ACPI_FUTURE_USAGE
495495
acpi_status
496-
acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
496+
acpi_os_get_physical_address(void *virt, acpi_physical_address *phys)
497497
{
498498
if (!phys || !virt)
499499
return AE_BAD_PARAMETER;
@@ -784,7 +784,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
784784

785785
#ifdef CONFIG_PCI
786786
acpi_status
787-
acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
787+
acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, u32 reg,
788788
u64 *value, u32 width)
789789
{
790790
int result, size;
@@ -816,7 +816,7 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
816816
}
817817

818818
acpi_status
819-
acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
819+
acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id, u32 reg,
820820
u64 value, u32 width)
821821
{
822822
int result, size;
@@ -1067,6 +1067,7 @@ acpi_status acpi_os_execute(acpi_execute_type type,
10671067
struct acpi_os_dpc *dpc;
10681068
struct workqueue_struct *queue;
10691069
int ret;
1070+
10701071
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
10711072
"Scheduling function [%p(%p)] for deferred execution.\n",
10721073
function, context));
@@ -1197,7 +1198,7 @@ bool acpi_queue_hotplug_work(struct work_struct *work)
11971198
}
11981199

11991200
acpi_status
1200-
acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
1201+
acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle *handle)
12011202
{
12021203
struct semaphore *sem = NULL;
12031204

@@ -1522,6 +1523,7 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
15221523
__acquires(lockp)
15231524
{
15241525
acpi_cpu_flags flags;
1526+
15251527
spin_lock_irqsave(lockp, flags);
15261528
return flags;
15271529
}
@@ -1554,7 +1556,7 @@ void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
15541556
******************************************************************************/
15551557

15561558
acpi_status
1557-
acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1559+
acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t **cache)
15581560
{
15591561
*cache = kmem_cache_create(name, size, 0, 0, NULL);
15601562
if (*cache == NULL)
@@ -1575,10 +1577,10 @@ acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
15751577
*
15761578
******************************************************************************/
15771579

1578-
acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1580+
acpi_status acpi_os_purge_cache(acpi_cache_t *cache)
15791581
{
15801582
kmem_cache_shrink(cache);
1581-
return (AE_OK);
1583+
return AE_OK;
15821584
}
15831585

15841586
/*******************************************************************************
@@ -1594,10 +1596,10 @@ acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
15941596
*
15951597
******************************************************************************/
15961598

1597-
acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1599+
acpi_status acpi_os_delete_cache(acpi_cache_t *cache)
15981600
{
15991601
kmem_cache_destroy(cache);
1600-
return (AE_OK);
1602+
return AE_OK;
16011603
}
16021604

16031605
/*******************************************************************************
@@ -1614,10 +1616,10 @@ acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
16141616
*
16151617
******************************************************************************/
16161618

1617-
acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1619+
acpi_status acpi_os_release_object(acpi_cache_t *cache, void *object)
16181620
{
16191621
kmem_cache_free(cache, object);
1620-
return (AE_OK);
1622+
return AE_OK;
16211623
}
16221624
#endif
16231625

@@ -1708,6 +1710,7 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
17081710
u32 pm1b_control)
17091711
{
17101712
int rc = 0;
1713+
17111714
if (__acpi_os_prepare_sleep)
17121715
rc = __acpi_os_prepare_sleep(sleep_state,
17131716
pm1a_control, pm1b_control);
@@ -1730,6 +1733,7 @@ acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
17301733
u32 val_b)
17311734
{
17321735
int rc = 0;
1736+
17331737
if (__acpi_os_prepare_extended_sleep)
17341738
rc = __acpi_os_prepare_extended_sleep(sleep_state,
17351739
val_a, val_b);

drivers/acpi/scan.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
289289
return 0;
290290
}
291291

292-
static int acpi_scan_device_not_present(struct acpi_device *adev)
292+
static int acpi_scan_device_not_enumerated(struct acpi_device *adev)
293293
{
294294
if (!acpi_device_enumerated(adev)) {
295-
dev_warn(&adev->dev, "Still not present\n");
295+
dev_warn(&adev->dev, "Still not enumerated\n");
296296
return -EALREADY;
297297
}
298298
acpi_bus_trim(adev);
@@ -304,7 +304,7 @@ static int acpi_scan_device_check(struct acpi_device *adev)
304304
int error;
305305

306306
acpi_bus_get_status(adev);
307-
if (adev->status.present || adev->status.functional) {
307+
if (acpi_device_is_present(adev)) {
308308
/*
309309
* This function is only called for device objects for which
310310
* matching scan handlers exist. The only situation in which
@@ -327,7 +327,7 @@ static int acpi_scan_device_check(struct acpi_device *adev)
327327
error = -ENODEV;
328328
}
329329
} else {
330-
error = acpi_scan_device_not_present(adev);
330+
error = acpi_scan_device_not_enumerated(adev);
331331
}
332332
return error;
333333
}
@@ -338,8 +338,8 @@ static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used)
338338
int error;
339339

340340
acpi_bus_get_status(adev);
341-
if (!(adev->status.present || adev->status.functional)) {
342-
acpi_scan_device_not_present(adev);
341+
if (!acpi_device_is_present(adev)) {
342+
acpi_scan_device_not_enumerated(adev);
343343
return 0;
344344
}
345345
if (handler && handler->hotplug.scan_dependent)

0 commit comments

Comments
 (0)