Commit 3c87f372 authored by Dan Williams's avatar Dan Williams
Browse files

acpi, nfit: fix acpi_get_table leak



Calls to acpi_get_table() must be paired with acpi_put_table() to undo
the mapping established by acpi_tb_acquire_table().

It turns out this has no effect in practice since the NFIT will already
be mapped to support the /sys/firmware/acpi/tables/NFIT attribute in
sysfs.

Fixes: 6b11d1d6 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
Cc: Lv Zheng <lv.zheng@intel.com>
Reported-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent f2668fa7
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -2831,6 +2831,11 @@ void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev)
}
}
EXPORT_SYMBOL_GPL(acpi_nfit_desc_init);
EXPORT_SYMBOL_GPL(acpi_nfit_desc_init);


static void acpi_nfit_put_table(void *table)
{
	acpi_put_table(table);
}

static int acpi_nfit_add(struct acpi_device *adev)
static int acpi_nfit_add(struct acpi_device *adev)
{
{
	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -2847,6 +2852,10 @@ static int acpi_nfit_add(struct acpi_device *adev)
		dev_dbg(dev, "failed to find NFIT at startup\n");
		dev_dbg(dev, "failed to find NFIT at startup\n");
		return 0;
		return 0;
	}
	}

	rc = devm_add_action_or_reset(dev, acpi_nfit_put_table, tbl);
	if (rc)
		return rc;
	sz = tbl->length;
	sz = tbl->length;


	acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL);
	acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL);