From: Rafael J. Wysocki Date: Tue, 18 Jun 2013 22:44:45 +0000 (+0200) Subject: ACPI / PM: Fix error code path for power resources initialization X-Git-Tag: v3.9.8~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb8b3337e5cb2adf7d75f0842522e4ff5847cd90;p=thirdparty%2Fkernel%2Fstable.git ACPI / PM: Fix error code path for power resources initialization commit 6ee22e9d59151550a55d370b14109bdae8b58bda upstream. Commit 781d737 (ACPI: Drop power resources driver) introduced a bug in the power resources initialization error code path causing a NULL pointer to be referenced in acpi_release_power_resource() if there's an error triggering a jump to the 'err' label in acpi_add_power_resource(). This happens because the list_node field of struct acpi_power_resource has not been initialized yet at this point and doing a list_del() on it is a bad idea. To prevent this problem from occuring, initialize the list_node field of struct acpi_power_resource upfront. Reported-by: Mika Westerberg Tested-by: Lan Tianyu Signed-off-by: Rafael J. Wysocki Acked-by: Yasuaki Ishimatsu Reviewed-by: Mika Westerberg Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 34f5ef11d427b..4d0624f8d20bc 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -865,6 +865,7 @@ int acpi_add_power_resource(acpi_handle handle) ACPI_STA_DEFAULT); mutex_init(&resource->resource_lock); INIT_LIST_HEAD(&resource->dependent); + INIT_LIST_HEAD(&resource->list_node); resource->name = device->pnp.bus_id; strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_POWER_CLASS);