Skip to content

Commit 9f1048d

Browse files
djbwstellarhopper
authored andcommitted
ACPI: NFIT: Fix ARS zero-sized allocation
Pending commit in -next "devres: handle zero size in devm_kmalloc()" triggers a boot regression due to the ARS implementation expecting NULL from a zero-sized allocation. Avoid the zero-sized allocation by skipping ARS, otherwise crashes with the following signature when de-referencing ZERO_SIZE_PTR. BUG: kernel NULL pointer dereference, address: 0000000000000018 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page RIP: 0010:__acpi_nfit_scrub+0x28a/0x350 [nfit] [..] Call Trace: ? acpi_nfit_query_poison+0x6a/0x180 [nfit] acpi_nfit_scrub+0x36/0xb0 [nfit] process_one_work+0x23c/0x580 worker_thread+0x50/0x3b0 Otherwise the implementation correctly aborts when NULL is returned from devm_kzalloc() in ars_status_alloc(). Link: https://lore.kernel.org/r/159624590643.3037264.14157533719042907758.stgit@dwillia2-desk3.amr.corp.intel.com Cc: Vishal Verma <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Ira Weiny <[email protected]> Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Vishal Verma <[email protected]>
1 parent 49688e6 commit 9f1048d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/acpi/nfit/core.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,7 +3334,7 @@ static void acpi_nfit_init_ars(struct acpi_nfit_desc *acpi_desc,
33343334
static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
33353335
{
33363336
struct nfit_spa *nfit_spa;
3337-
int rc;
3337+
int rc, do_sched_ars = 0;
33383338

33393339
set_bit(ARS_VALID, &acpi_desc->scrub_flags);
33403340
list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
@@ -3346,14 +3346,21 @@ static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
33463346
}
33473347
}
33483348

3349-
list_for_each_entry(nfit_spa, &acpi_desc->spas, list)
3349+
list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
33503350
switch (nfit_spa_type(nfit_spa->spa)) {
33513351
case NFIT_SPA_VOLATILE:
33523352
case NFIT_SPA_PM:
33533353
/* register regions and kick off initial ARS run */
33543354
rc = ars_register(acpi_desc, nfit_spa);
33553355
if (rc)
33563356
return rc;
3357+
3358+
/*
3359+
* Kick off background ARS if at least one
3360+
* region successfully registered ARS
3361+
*/
3362+
if (!test_bit(ARS_FAILED, &nfit_spa->ars_state))
3363+
do_sched_ars++;
33573364
break;
33583365
case NFIT_SPA_BDW:
33593366
/* nothing to register */
@@ -3372,8 +3379,10 @@ static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
33723379
/* don't register unknown regions */
33733380
break;
33743381
}
3382+
}
33753383

3376-
sched_ars(acpi_desc);
3384+
if (do_sched_ars)
3385+
sched_ars(acpi_desc);
33773386
return 0;
33783387
}
33793388

0 commit comments

Comments
 (0)