ACPI / memhotplug: Fix a stale pointer in error path
authorToshi Kani <toshi.kani@hp.com>
Wed, 10 Jul 2013 16:47:13 +0000 (10:47 -0600)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 2 Aug 2013 20:14:55 +0000 (22:14 +0200)
commit d19f503e22316a84c39bc19445e0e4fdd49b3532 upstream.

device->driver_data needs to be cleared when releasing its data,
mem_device, in an error path of acpi_memory_device_add().

The function evaluates the _CRS of memory device objects, and fails
when it gets an unexpected resource or cannot allocate memory.  A
kernel crash or data corruption may occur when the kernel accesses
the stale pointer.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/acpi/acpi_memhotplug.c

index d985713..f81597f 100644 (file)
@@ -421,6 +421,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
        /* Get the range from the _CRS */
        result = acpi_memory_get_device_resources(mem_device);
        if (result) {
        /* Get the range from the _CRS */
        result = acpi_memory_get_device_resources(mem_device);
        if (result) {
+               device->driver_data = NULL;
                kfree(mem_device);
                return result;
        }
                kfree(mem_device);
                return result;
        }