• Rafael J. Wysocki's avatar
    ACPI / PNP: Do not crash due to stale pointer use during system resume · d7234ac9
    Rafael J. Wysocki authored
    commit a6b5e88c upstream.
    
    During resume from system suspend the 'data' field of
    struct pnp_dev in pnpacpi_set_resources() may be a stale pointer,
    due to removal of the associated ACPI device node object in the
    previous suspend-resume cycle.  This happens, for example, if a
    dockable machine is booted in the docking station and then suspended
    and resumed and suspended again.  If that happens,
    pnpacpi_build_resource_template() called from pnpacpi_set_resources()
    attempts to use that pointer and crashes.
    
    However, pnpacpi_set_resources() actually checks the device's ACPI
    handle, attempts to find the ACPI device node object attached to it
    and returns an error code if that fails, so in fact it knows what the
    correct value of dev->data should be.  Use this observation to update
    dev->data with the correct value if necessary and dump a call trace
    if that's the case (once).
    
    We still need to fix the root cause of this issue, but preventing
    systems from crashing because of it is an improvement too.
    Reported-and-tested-by: default avatarZdenek Kabelac <zdenek.kabelac@gmail.com>
    References: https://bugzilla.kernel.org/show_bug.cgi?id=51071Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    d7234ac9
core.c 9.93 KB