]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.57/acpi-pnp-do-not-crash-due-to-stale-pointer-use-during-system-resume.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.57 / acpi-pnp-do-not-crash-due-to-stale-pointer-use-during-system-resume.patch
1 From a6b5e88c0e42093b9057856f35770966c8c591e3 Mon Sep 17 00:00:00 2001
2 From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
3 Date: Fri, 30 Nov 2012 13:05:05 +0100
4 Subject: ACPI / PNP: Do not crash due to stale pointer use during system resume
5
6 From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
7
8 commit a6b5e88c0e42093b9057856f35770966c8c591e3 upstream.
9
10 During resume from system suspend the 'data' field of
11 struct pnp_dev in pnpacpi_set_resources() may be a stale pointer,
12 due to removal of the associated ACPI device node object in the
13 previous suspend-resume cycle. This happens, for example, if a
14 dockable machine is booted in the docking station and then suspended
15 and resumed and suspended again. If that happens,
16 pnpacpi_build_resource_template() called from pnpacpi_set_resources()
17 attempts to use that pointer and crashes.
18
19 However, pnpacpi_set_resources() actually checks the device's ACPI
20 handle, attempts to find the ACPI device node object attached to it
21 and returns an error code if that fails, so in fact it knows what the
22 correct value of dev->data should be. Use this observation to update
23 dev->data with the correct value if necessary and dump a call trace
24 if that's the case (once).
25
26 We still need to fix the root cause of this issue, but preventing
27 systems from crashing because of it is an improvement too.
28
29 Reported-and-tested-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
30 References: https://bugzilla.kernel.org/show_bug.cgi?id=51071
31 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34 ---
35 drivers/pnp/pnpacpi/core.c | 3 +++
36 1 file changed, 3 insertions(+)
37
38 --- a/drivers/pnp/pnpacpi/core.c
39 +++ b/drivers/pnp/pnpacpi/core.c
40 @@ -94,6 +94,9 @@ static int pnpacpi_set_resources(struct
41 return -ENODEV;
42 }
43
44 + if (WARN_ON_ONCE(acpi_dev != dev->data))
45 + dev->data = acpi_dev;
46 +
47 ret = pnpacpi_build_resource_template(dev, &buffer);
48 if (ret)
49 return ret;