Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336684
b: refs/heads/master
c: 386e52b
h: refs/heads/master
v: v3
  • Loading branch information
Wen Congyang authored and Rafael J. Wysocki committed Nov 16, 2012
1 parent 159c063 commit 48e0a5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 315bbae9c5cb1f54a6d6fd47b9cf325fbedccf05
refs/heads/master: 386e52b95550db87c93455e3c0efe3cc4543f036
27 changes: 21 additions & 6 deletions trunk/drivers/acpi/acpi_memhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,28 @@ acpi_memory_get_resource(struct acpi_resource *resource, void *context)
return AE_OK;
}

static void
acpi_memory_free_device_resources(struct acpi_memory_device *mem_device)
{
struct acpi_memory_info *info, *n;

list_for_each_entry_safe(info, n, &mem_device->res_list, list)
kfree(info);
INIT_LIST_HEAD(&mem_device->res_list);
}

static int
acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
{
acpi_status status;
struct acpi_memory_info *info, *n;


if (!list_empty(&mem_device->res_list))
return 0;

status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
acpi_memory_get_resource, mem_device);
if (ACPI_FAILURE(status)) {
list_for_each_entry_safe(info, n, &mem_device->res_list, list)
kfree(info);
INIT_LIST_HEAD(&mem_device->res_list);
acpi_memory_free_device_resources(mem_device);
return -EINVAL;
}

Expand Down Expand Up @@ -363,6 +369,15 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
return;
}

static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
{
if (!mem_device)
return;

acpi_memory_free_device_resources(mem_device);
kfree(mem_device);
}

static int acpi_memory_device_add(struct acpi_device *device)
{
int result;
Expand Down Expand Up @@ -427,7 +442,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
if (result)
return result;

kfree(mem_device);
acpi_memory_device_free(mem_device);

return 0;
}
Expand Down

0 comments on commit 48e0a5f

Please sign in to comment.